Gregniuki commited on
Commit
175e58b
·
1 Parent(s): 8f17915

Update templates/login.html

Browse files
Files changed (1) hide show
  1. templates/login.html +22 -18
templates/login.html CHANGED
@@ -40,25 +40,29 @@
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>
 
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>