|
|
@@ -1,5 +1,7 @@
|
|
|
+import { routerRedux } from 'dva/router';
|
|
|
import { fakeAccountLogin } from '../services/api';
|
|
|
import { setAuthority } from '../utils/authority';
|
|
|
+import { reloadAuthorized } from '../utils/Authorized';
|
|
|
|
|
|
export default {
|
|
|
namespace: 'login',
|
|
|
@@ -17,11 +19,8 @@ export default {
|
|
|
});
|
|
|
// Login successfully
|
|
|
if (response.status === 'ok') {
|
|
|
- // 非常粗暴的跳转,登陆成功之后权限会变成user或admin,会自动重定向到主页
|
|
|
- // Login success after permission changes to admin or user
|
|
|
- // The refresh will automatically redirect to the home page
|
|
|
- // yield put(routerRedux.push('/'));
|
|
|
- window.location.reload();
|
|
|
+ reloadAuthorized();
|
|
|
+ yield put(routerRedux.push('/'));
|
|
|
}
|
|
|
},
|
|
|
*logout(_, { put, select }) {
|
|
|
@@ -33,9 +32,6 @@ export default {
|
|
|
urlParams.searchParams.set('redirect', pathname);
|
|
|
window.history.replaceState(null, 'login', urlParams.href);
|
|
|
} finally {
|
|
|
- // yield put(routerRedux.push('/user/login'));
|
|
|
- // Login out after permission changes to admin or user
|
|
|
- // The refresh will automatically redirect to the login page
|
|
|
yield put({
|
|
|
type: 'changeLoginStatus',
|
|
|
payload: {
|
|
|
@@ -43,7 +39,8 @@ export default {
|
|
|
currentAuthority: 'guest',
|
|
|
},
|
|
|
});
|
|
|
- window.location.reload();
|
|
|
+ reloadAuthorized();
|
|
|
+ yield put(routerRedux.push('/user/login'));
|
|
|
}
|
|
|
},
|
|
|
},
|