diff options
Diffstat (limited to 'src/scripts/user.ts')
| -rw-r--r-- | src/scripts/user.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/scripts/user.ts b/src/scripts/user.ts index dda2dcab..66e44b21 100644 --- a/src/scripts/user.ts +++ b/src/scripts/user.ts @@ -30,13 +30,13 @@ window["___gcfg"] = { }; /** - * Google signin button + * Google signin button. */ window["gapiSigninButton"] = () => { gapi.signin2.render('google-signin', { 'scope': 'profile email', 'onsuccess': (googleUser) => { - let auth2 = gapi.auth2.getAuthInstance(); + const auth2 = gapi.auth2.getAuthInstance(); // Handle signout click $("nav .user .sign-out").click(() => { @@ -47,12 +47,12 @@ window["gapiSigninButton"] = () => { }); // Check if the token has expired - let currentTime = (new Date()).getTime() / 1000; + const currentTime = (new Date()).getTime() / 1000; if (parseInt(localStorage.getItem("googleTokenExpiration")) - currentTime <= 0) { auth2.signIn().then(() => { localStorage.setItem("googleToken", googleUser.getAuthResponse().id_token); - let expirationTime = (new Date()).getTime() / 1000 + parseInt(googleUser.getAuthResponse().expires_in) - 5; + const expirationTime = (new Date()).getTime() / 1000 + parseInt(googleUser.getAuthResponse().expires_in) - 5; localStorage.setItem("googleTokenExpiration", expirationTime.toString()); }); } @@ -65,12 +65,14 @@ window["gapiSigninButton"] = () => { }; +/** + * Removes session storage items. + */ export function removeUserInfo() { - // Remove session storage items localStorage.removeItem("googleToken"); localStorage.removeItem("googleTokenExpiration"); localStorage.removeItem("googleName"); localStorage.removeItem("googleEmail"); localStorage.removeItem("userId"); localStorage.removeItem("simulationId"); -}
\ No newline at end of file +} |
