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

View File

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

View File

@ -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)
};
}