From 80c33f5303e2c083841933de4338f7e5d15de972 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 3 Apr 2017 09:20:59 +0200 Subject: Factor out hardcoded SERVER_BASE_URL --- src/404.html | 2 +- src/index.html | 4 ++-- src/scripts/controllers/connection/socket.ts | 2 +- src/scripts/splash.entry.ts | 4 ++-- src/scripts/user.ts | 17 ++--------------- 5 files changed, 8 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/404.html b/src/404.html index 84182341..10f79525 100644 --- a/src/404.html +++ b/src/404.html @@ -20,7 +20,7 @@
Got lost?_
- GET ME BACK TO OPENDC + GET ME BACK TO OPENDC diff --git a/src/index.html b/src/index.html index 8ea4ce49..c58aaf01 100644 --- a/src/index.html +++ b/src/index.html @@ -11,8 +11,8 @@ - - + + diff --git a/src/scripts/controllers/connection/socket.ts b/src/scripts/controllers/connection/socket.ts index c23495f1..91a0f9e4 100644 --- a/src/scripts/controllers/connection/socket.ts +++ b/src/scripts/controllers/connection/socket.ts @@ -15,7 +15,7 @@ export class SocketController { this.callbacks = {}; this._cacheController = new CacheController(); - this._socket = io.connect('https://opendc.ewi.tudelft.nl:443'); + this._socket = io.connect('SERVER_BASE_URL'); this._socket.on('connect', onConnect); this._socket.on('response', (jsonResponse: string) => { diff --git a/src/scripts/splash.entry.ts b/src/scripts/splash.entry.ts index 700f52bb..6abd9518 100644 --- a/src/scripts/splash.entry.ts +++ b/src/scripts/splash.entry.ts @@ -119,7 +119,7 @@ window["renderButton"] = () => { // Calculate token expiration time (in seconds since epoch) const expirationTime = (new Date()).getTime() / 1000 + googleUser.getAuthResponse().expires_in - 5; - $.post('https://opendc.ewi.tudelft.nl/tokensignin', { + $.post('SERVER_BASE_URL/tokensignin', { idtoken: id_token }, (data: any) => { // Save user information in session storage for later use on other pages @@ -146,7 +146,7 @@ window["renderButton"] = () => { }); }, 'onfailure': () => { - console.log("Oops, something went wrong with your Google signin... Try again?") + console.log("Oops, something went wrong with your Google signin... Try again?"); } }); }; diff --git a/src/scripts/user.ts b/src/scripts/user.ts index 66e44b21..e9d13091 100644 --- a/src/scripts/user.ts +++ b/src/scripts/user.ts @@ -2,24 +2,11 @@ import * as $ from "jquery"; -const LOCAL_MODE = (document.location.hostname === "localhost"); - // Redirect the user to the splash page, if not signed in -if (!LOCAL_MODE && localStorage.getItem("googleToken") === null) { +if (localStorage.getItem("googleToken") === null) { window.location.replace("/"); } -// Fill session storage with mock data during LOCAL_MODE -if (LOCAL_MODE) { - localStorage.setItem("googleToken", ""); - localStorage.setItem("googleTokenExpiration", "2000000000"); - localStorage.setItem("googleName", "John Doe"); - localStorage.setItem("googleEmail", "john@doe.com"); - localStorage.setItem("userId", "2"); - localStorage.setItem("simulationId", "1"); - localStorage.setItem("simulationAuthLevel", "OWN"); -} - // Set the username in the navbar $("nav .user .username").text(localStorage.getItem("googleName")); @@ -59,7 +46,7 @@ window["gapiSigninButton"] = () => { }, 'onfailure': () => { window.location.href = "/"; - console.log("Oops, something went wrong with your Google signin... Try again?") + console.log("Oops, something went wrong with your Google signin... Try again?"); } }); }; -- cgit v1.2.3