-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
55 lines (49 loc) · 1.45 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var SUPABASE_URL = "https://sunpjejrjxldpkdpacor.supabase.co";
var SUPABASE_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN1bnBqZWpyanhsZHBrZHBhY29yIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzE3Mzg4MjAsImV4cCI6MTk4NzMxNDgyMH0.9GyzTiRwXyuuyuvHl1TcCftFUFI-OaqAAt14kDh9HnI";
var supabase = supabase.createClient(SUPABASE_URL, SUPABASE_KEY);
var token = null;
function setToken(newToken) {
token = newToken;
}
function signup(event) {
event.preventDefault();
var email = event.target[0].value;
var password = event.target[1].value;
supabase.auth
.signUp({ email, password })
.then((response) => {
response.error ? alert(response.error.message) : setToken(response);
})
.catch((err) => {
alert(err);
});
}
function login(event) {
event.preventDefault();
var email = event.target[0].value;
var password = event.target[1].value;
supabase.auth
.signUp({ email, password })
.then((response) => {
console.log(response);
debugger;
if (response.error) {
alert(response.error.message);
} else {
setToken(response);
window.location.reload();
}
})
.catch((err) => {
alert(err);
});
}
function getUser() {
return supabase.auth.user();
}
function search(event) {
event.preventDefault();
const query = event.target[0].value;
window.location.href = "/search.html?q=" + query;
}