Ivan - Fix session [skip ci]

This commit is contained in:
ivan 2017-02-25 16:16:58 -03:00
parent 7f1047b311
commit a60f6e9cd9
3 changed files with 35 additions and 15 deletions

View File

@ -4,10 +4,13 @@ import sessionStore from 'lib-app/session-store';
import store from 'app/store'; import store from 'app/store';
export default { export default {
login(loginData) { login(loginData) {
return { return {
type: 'LOGIN', type: 'LOGIN',
payload: API.call({ payload: new Promise((resolve, reject) => {
let loginCall = () => {
API.call({
path: '/user/login', path: '/user/login',
data: loginData data: loginData
}).then((result) => { }).then((result) => {
@ -17,7 +20,20 @@ export default {
store.dispatch(AdminDataActions.retrieveCustomResponses()); store.dispatch(AdminDataActions.retrieveCustomResponses());
} }
return result; 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 { } else {
store.dispatch(this.autoLogin()); store.dispatch(this.autoLogin());
} }
} else { } else if(sessionStore.isLoggedIn()) {
store.dispatch({ store.dispatch({
type: 'SESSION_CHECKED' type: 'SESSION_CHECKED'
}); });

View File

@ -46,6 +46,10 @@
} }
} }
.ticket-list__number {
text-align: center;
}
.signup-widget { .signup-widget {
background-color: $very-light-grey; background-color: $very-light-grey;
} }

View File

@ -74,10 +74,10 @@ class SessionStore {
supportedLanguages: JSON.parse(this.getItem('supportedLanguages')), supportedLanguages: JSON.parse(this.getItem('supportedLanguages')),
layout: this.getItem('layout'), layout: this.getItem('layout'),
title: this.getItem('title'), title: this.getItem('title'),
registration: !!(this.getItem('registration') * 1), registration: (this.getItem('registration') * 1),
'user-system-enabled': !!(this.getItem('user-system-enabled') * 1), 'user-system-enabled': (this.getItem('user-system-enabled') * 1),
'allow-attachments': !!(this.getItem('allow-attachments') * 1), 'allow-attachments': (this.getItem('allow-attachments') * 1),
'maintenance-mode': !!(this.getItem('maintenance-mode') * 1) 'maintenance-mode': (this.getItem('maintenance-mode') * 1)
}; };
} }