summaryrefslogtreecommitdiff
path: root/src/scripts/user.ts
diff options
context:
space:
mode:
authorGeorgios Andreadis <G.Andreadis@student.tudelft.nl>2017-01-27 10:26:54 +0100
committerGitHub <noreply@github.com>2017-01-27 10:26:54 +0100
commit50fcb0634c9ebe894988103184d50d372bc76907 (patch)
tree5af172c03599f7c680cd32205eab5329b841c85c /src/scripts/user.ts
parent3ad08353d289720cf8f43e1dba078da43c35e97d (diff)
parentb462c9183ec7c2e41f14daad49f03d8afaa4ec59 (diff)
Merge pull request #4 from tudelft-atlarge/states-batch-fetch
Fetch experiment states in one batch
Diffstat (limited to 'src/scripts/user.ts')
-rw-r--r--src/scripts/user.ts14
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
+}