diff --git a/client/src/actions/session-actions.js b/client/src/actions/session-actions.js index 4a329e90..44e0aba9 100644 --- a/client/src/actions/session-actions.js +++ b/client/src/actions/session-actions.js @@ -4,20 +4,36 @@ import sessionStore from 'lib-app/session-store'; import store from 'app/store'; export default { + login(loginData) { return { type: 'LOGIN', - payload: API.call({ - path: '/user/login', - data: loginData - }).then((result) => { - store.dispatch(this.getUserData(result.data.userId, result.data.token, result.data.staff)); - - if(result.data.staff) { - store.dispatch(AdminDataActions.retrieveCustomResponses()); - } + payload: new Promise((resolve, reject) => { + let loginCall = () => { + API.call({ + path: '/user/login', + data: loginData + }).then((result) => { + store.dispatch(this.getUserData(result.data.userId, result.data.token, result.data.staff)); - return result; + if(result.data.staff) { + store.dispatch(AdminDataActions.retrieveCustomResponses()); + } + + resolve(result); + }).catch((result) => { + if(result.message === 'SESSION_EXISTS') { + API.call({ + path: '/user/logout', + data: {} + }).then(loginCall); + } else { + reject(result); + } + }) + }; + + loginCall(); }) }; }, @@ -93,7 +109,7 @@ export default { } else { store.dispatch(this.autoLogin()); } - } else { + } else if(sessionStore.isLoggedIn()) { store.dispatch({ type: 'SESSION_CHECKED' }); diff --git a/client/src/app/app.scss b/client/src/app/app.scss index 5a62ae04..77a8ea7a 100644 --- a/client/src/app/app.scss +++ b/client/src/app/app.scss @@ -46,6 +46,10 @@ } } + .ticket-list__number { + text-align: center; + } + .signup-widget { background-color: $very-light-grey; } diff --git a/client/src/lib-app/session-store.js b/client/src/lib-app/session-store.js index 142c4b6c..542a0b90 100644 --- a/client/src/lib-app/session-store.js +++ b/client/src/lib-app/session-store.js @@ -74,10 +74,10 @@ class SessionStore { supportedLanguages: JSON.parse(this.getItem('supportedLanguages')), layout: this.getItem('layout'), title: this.getItem('title'), - registration: !!(this.getItem('registration') * 1), - 'user-system-enabled': !!(this.getItem('user-system-enabled') * 1), - 'allow-attachments': !!(this.getItem('allow-attachments') * 1), - 'maintenance-mode': !!(this.getItem('maintenance-mode') * 1) + registration: (this.getItem('registration') * 1), + 'user-system-enabled': (this.getItem('user-system-enabled') * 1), + 'allow-attachments': (this.getItem('allow-attachments') * 1), + 'maintenance-mode': (this.getItem('maintenance-mode') * 1) }; }