Gregniuki commited on
Commit
8f17915
·
1 Parent(s): 81e21b2

Update templates/login.html

Browse files
Files changed (1) hide show
  1. templates/login.html +21 -10
templates/login.html CHANGED
@@ -38,17 +38,28 @@
38
  <!-- Google Sign-in Button -->
39
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
40
 
41
- <script>
42
- function onSignIn(googleUser) {
43
- // Get the Google user profile information
44
- var profile = googleUser.getBasicProfile();
45
-
46
- // You can now send this information to your server if needed
47
- // ...
48
 
49
- // Or simply redirect the user to a dashboard or home page
50
- }
51
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
54
  <script>
 
38
  <!-- Google Sign-in Button -->
39
  <div class="g-signin2" data-onsuccess="onSignIn"></div>
40
 
41
+ <script>
42
+ function onSignIn(googleUser) {
43
+ var id_token = googleUser.getAuthResponse().id_token;
 
 
 
 
44
 
45
+ // Send the ID token to your server with a POST request
46
+ fetch('/verify-google-token', {
47
+ method: 'POST',
48
+ headers: {
49
+ 'Content-Type': 'application/json'
50
+ },
51
+ body: JSON.stringify({ token: id_token })
52
+ })
53
+ .then(response => response.json())
54
+ .then(data => {
55
+ // Handle response data
56
+ console.log(data);
57
+ // Redirect to dashboard or other page if needed
58
+ window.location.href = '/dashboard';
59
+ })
60
+ .catch(error => console.error('Error:', error));
61
+ }
62
+ </script>
63
 
64
  <script src="https://www.google.com/recaptcha/api.js" async defer></script>
65
  <script>