about summary refs log tree commit diff
path: root/client/index.html
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·27+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-02T20·27+0100
commitb9ed4a2dc170a3a4b6c1095cdfc79e49292f315d (patch)
treedb81e5f3fb515d9d5ca8003968c11b6b09591a82 /client/index.html
parentd6b91b93cbb42170249eb17eb7d0cb1c1a31f44a (diff)
Partially support federated login
Two things:
1. I've never attempted to support this before.
2. It seems surprisingly and perhaps deceptively simpler than what I
   expected. I'm unsure what to do once Google's API authenticates the user. I
   currently look-up the user's role, trips, etc. using their email address. The
   role is stored in the Accounts table alongside username, email, password. I
   will speak with the interviewer tomorrow about this.
Diffstat (limited to 'client/index.html')
-rw-r--r--client/index.html26
1 files changed, 13 insertions, 13 deletions
diff --git a/client/index.html b/client/index.html
index df63ffa062eb..9e6cef70dbb4 100644
--- a/client/index.html
+++ b/client/index.html
@@ -13,19 +13,7 @@
     <div id="mount"></div>
     <script>
      function onSignIn(googleUser) {
-       var profile = googleUser.getBasicProfile();
-       console.log('ID: ' + profile.getId());
-       console.log('Name: ' + profile.getName());
-       console.log('Image URL: ' + profile.getImageUrl());
-       console.log('Email: ' + profile.getEmail());
-     }
-
-     function signOut() {
-       console.log('Signing out!');
-       var auth2 = gapi.auth2.getAuthInstance();
-       auth2.signOut().then(function() {
-         console.log('User signed out.');
-       });
+       console.log(googleUser);
      }
 
      var app = Elm.Main.init({node: document.getElementById("mount")});
@@ -33,6 +21,18 @@
      app.ports.printPage.subscribe(function() {
        window.print();
      });
+
+     app.ports.googleSignIn.subscribe(function() {
+       var auth2 = gapi.auth2.getAuthInstance();
+       var googleUser = auth2.signIn();
+     });
+
+     app.ports.googleSignOut.subscribe(function() {
+       var auth2 = gapi.auth2.getAuthInstance();
+       auth2.signOut().then(function() {
+         console.log('Google user successfully signed out.');
+       });
+     });
     </script>
   </body>
 </html>