-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (66 loc) · 2.88 KB
/
index.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="859063326524-i104bft5cv439l78ic5j5dhpvopjblem.apps.googleusercontent.com">
<script src="https://www.gstatic.com/firebasejs/8.2.6/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.6/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.6/firebase-database.js"></script>
<link rel="stylesheet" href="index.css">
</head>
<body>
<script>
if(localStorage["id"] && localStorage["name"] && localStorage["email"]){
console.log("already signed in as: " + localStorage["email"])
window.open ('registerInfo.html','_self',false);
}
var provider = new firebase.auth.GoogleAuthProvider();
function signInFunc() {
firebase.auth()
.signInWithPopup(provider)
.then((result) => {
/** @type {firebase.auth.OAuthCredential} */
var credential = result.credential;
// This gives you a Google Access Token. You can use it to access the Google API.
var token = credential.accessToken;
// The signed-in user info.
var user = result.user;
// console.log(user.displayName);
// console.log(user.uid);
setID(user.uid, user.displayName, user.email);
// ...
// document.getElementById("includedContent").style.visibility = "visible";
// document.getElementById("signInButton").style.visibility = "collapse";
window.open ('registerInfo.html','_self',false);
// window.location.href = "home.html";
}).catch((error) => {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
}
function setID(id, name, email){
console.log("setting")
localStorage["id"] = id;
console.log(localStorage["id"])
localStorage["name"] = name;
localStorage["email"] = email;
}
</script>
<script src = "config.js"></script>
<h1>Welcome to carpool!</h1>
<button id="signInButton" type="button" onclick="signInFunc()">Sign In</button>
</body>
</html>