Update templates/login.html
Browse files- templates/login.html +22 -18
templates/login.html
CHANGED
@@ -40,25 +40,29 @@
|
|
40 |
|
41 |
<script>
|
42 |
function onSignIn(googleUser) {
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
62 |
</script>
|
63 |
|
64 |
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
|
|
40 |
|
41 |
<script>
|
42 |
function onSignIn(googleUser) {
|
43 |
+
var id_token = googleUser.getAuthResponse().id_token;
|
44 |
|
45 |
+
fetch('/verify-google-token', {
|
46 |
+
method: 'POST',
|
47 |
+
headers: {
|
48 |
+
'Content-Type': 'application/json'
|
49 |
+
},
|
50 |
+
body: JSON.stringify({ token: id_token })
|
51 |
+
})
|
52 |
+
.then(response => {
|
53 |
+
if (response.redirected) {
|
54 |
+
// Follow the redirect from the server
|
55 |
+
window.location.href = response.url;
|
56 |
+
} else {
|
57 |
+
return response.json();
|
58 |
+
}
|
59 |
+
})
|
60 |
+
.then(data => {
|
61 |
+
// Handle response data if needed
|
62 |
+
console.log(data);
|
63 |
+
})
|
64 |
+
.catch(error => console.error('Error:', error));
|
65 |
+
}
|
66 |
</script>
|
67 |
|
68 |
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|