Use REST API result for check login message.

This commit is contained in:
Max Eddy
2017-06-16 13:04:27 -04:00
parent fd9b14a560
commit 4982d8a9ad
2 changed files with 6 additions and 7 deletions
+3 -3
View File
@@ -54,9 +54,9 @@ function configurePymParent(pymParent, opts) {
pymParent.sendMessage('config', JSON.stringify(config));
}
pymParent.onMessage('checkLogin', function(result) {
if (opts.onAuthChange) {
opts.onAuthChange(JSON.parse(result));
pymParent.onMessage('coral-check-login', function(result) {
if (opts.onCheckLogin) {
opts.onCheckLogin(JSON.parse(result));
}
});
+3 -4
View File
@@ -301,10 +301,12 @@ const checkLoginSuccess = (user, isAdmin) => ({
isAdmin
});
export const checkLogin = () => (dispatch, getState) => {
export const checkLogin = () => (dispatch) => {
dispatch(checkLoginRequest());
coralApi('/auth')
.then((result) => {
pym.sendMessage('coral-check-login', JSON.stringify(result));
if (!result.user) {
if (!bowser.safari && !bowser.ios) {
Storage.removeItem('token');
@@ -325,9 +327,6 @@ export const checkLogin = () => (dispatch, getState) => {
.catch((error) => {
console.error(error);
dispatch(checkLoginFailure(`${error.translation_key}`));
})
.then(() => {
pym.sendMessage('checkLogin', JSON.stringify(getState().auth));
});
};