mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Use REST API result for check login message.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user