-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
88 lines (78 loc) · 3.78 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
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mcf.db | Login</title>
<script src="https://kit.fontawesome.com/4467197cc4.js" crossorigin="anonymous"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Karla:wght@400;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/login.css">
</head>
<body>
<div id="container">
<img id="logo" src="assets/logo.png" alt="logo">
<p id="segment-header">NUS ComClub Feedback Mgmt.</p>
<div id="signin">
<img src="assets/google-png.png" alt="google" id="glogo">
<p>Continue with GSuite</p>
</div>
<p id="error-msg"></p>
<p id="seg-msg"><i class="fas fa-info-circle"></i> Issues logging in? Contact your IT Sec!</p>
</div>
</body>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-app.js";
import { getDatabase, get, onValue, child, ref, set, push } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-database.js";
import { getAuth, signInWithPopup, GoogleAuthProvider } from "https://www.gstatic.com/firebasejs/9.0.2/firebase-auth.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyCn9v6eXCTzJw7z_OHfpH4NEOw8mEnU62g",
authDomain: "mc-feedback.firebaseapp.com",
databaseURL: "https://mc-feedback-default-rtdb.asia-southeast1.firebasedatabase.app",
projectId: "mc-feedback",
storageBucket: "mc-feedback.appspot.com",
messagingSenderId: "821071166410",
appId: "1:821071166410:web:e2d3283e7b87b590eced33"
}
console.log("app loaded")
// Initialize Firebase
const app = initializeApp(firebaseConfig)
const signinBtn = document.getElementById("signin")
const errorBox = document.getElementById('error-msg')
const provider = new GoogleAuthProvider();
provider.setCustomParameters({
'login_hint': '[email protected]'
});
signinBtn.addEventListener("click", () => {
const auth = getAuth();
signInWithPopup(auth, provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
console.log(user)
if (user !== undefined) {
window.location.href = "dashboard.html"
}
// ...
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
errorBox.innerHTML = "Something went wrong. Try Again!!"
});
})
</script>
</html>