-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from JoelBerglund05/authentication
Authentication
- Loading branch information
Showing
6 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"liveServer.settings.port": 5501 | ||
} | ||
"liveServer.settings.port": 5501 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2' | ||
import { createClient } from "https://esm.sh/@supabase/supabase-js@2"; | ||
|
||
class DataBase { | ||
export default class DataBase { | ||
constructor() { | ||
this.supabase = createClient( | ||
"https://unswumzybkmeifdigbfn.supabase.co", | ||
"KEY", | ||
); | ||
|
||
} | ||
async GetARowFrow(table, idToRow) { | ||
try { | ||
const { data, error } = await this.supabase | ||
.from(table) | ||
.select() | ||
.eq('id', idToRow); | ||
console.log(table, data); | ||
return data; | ||
|
||
async GetARowFrom(table, idToRow) { | ||
const { data, error } = await this.supabase | ||
.from(table) | ||
.select() | ||
.eq("id", idToRow); | ||
|
||
if (error) { | ||
console.log("Kunde inte hämta data: ", error); | ||
return; | ||
} | ||
|
||
return data; | ||
} | ||
|
||
async SignUpUser(email, password) { | ||
if (password[0] !== password[1]) { | ||
alert("Lösenorden är inte samma"); | ||
return; | ||
} | ||
|
||
const { data, error } = await this.supabase.auth.signInWithOtp({ | ||
email: email, | ||
password: password, | ||
}); | ||
|
||
if (error) { | ||
console.log("kunde inte skapa konto: ", error); | ||
} | ||
catch (e) { | ||
console.log("An Error has occured: " + event); | ||
} | ||
|
||
async SignInUser(email) { | ||
const { data, error } = await this.supabase.auth.signInWithOtp({ | ||
email: email, | ||
password: password, | ||
}); | ||
if (error) { | ||
console.log("Kunde inte logga in användaren: ", error); | ||
} | ||
|
||
} | ||
} | ||
|
||
export default DataBase; | ||
async LogOutUser() { | ||
const { error } = await this.supabase.auth.signOut(); | ||
|
||
if (error) { | ||
console.log("Kunde inte logga ut användaren: ", error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default class EventManager { | ||
EventListener(element, eventType, method) { | ||
if (element) { | ||
element.addEventListener(eventType, method); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<input id="email" type="text" placeholder="Email" /> | ||
<input id="password1" type="text" placeholder="Lösenord" /> | ||
<input id="password2" type="text" placeholder="Lösenord" /> | ||
<button id="createAccount">Skapa konto</button> | ||
<button id="signIn">Logga in</button> | ||
<script type="module" src="js/main.js"></script> | ||
</body> | ||
</html> |