/ My Projects / Web Development / Google Auth Implementation

Google Auth

So, lately I have been experimenting with Google APIs, and decided to implement the Google Authentication on my website. At the moment, it is only half-implemented, but if you click on the copyright menu on the main website, you will see a name identifier, as well as a Google Sign-In button. You can click the button to log in, and (upon refreshing) the Name identifier will update. If you then click sign out, it will log you out of the website, and the Name identifier will change back to 'Guest'.

I have not implemented a handler for protecting pages yet, but I am currently working on it, and plan to integrate it with my JSURL Project so that webpages can forward to a login handler, and be redirected back to a set page after authentication, as follows:

glmills.gq/login/?doLoginRedir=URL/to/redirect/to

So for example, if you click the link below, it will log you in and send you to the Projects page.

http://glmills.gq/login/index.html?doLoginRedir=/projects

This is not implemented yet, however. The in-progress source code is available in the aforementioned files. For those of you curious about how I handled sign ins, here you go:

              
function onSignIn(googleUser) {
              var profile = googleUser.getBasicProfile();
              id = profile.getId();
              name = profile.getName();
              imgurl = profile.getImageUrl();
              email = profile.getEmail();
              sessionKey = email;
              sessionVal = localStorage.getItem(sessionKey);
              localStorage.setItem(sessionKey, "in");
              if (onLoginRedir != undefined){
                window.location=onLoginRedir;
              }
              else {console.log("Login Successful")}
            }