admin-web 接入新的登陆接口

This commit is contained in:
YunaiV
2020-07-04 21:35:15 +08:00
parent 41514100e0
commit d89e5bad98
4 changed files with 15 additions and 37 deletions

View File

@@ -1,7 +1,7 @@
import { routerRedux } from 'dva/router';
import { stringify } from 'qs';
import { getFakeCaptcha } from '@/services/api';
import { oauth2UsernameAuthenticate } from '@/services/system';
import { passportLogin } from '@/services/system';
import { setAuthority } from '@/utils/authority';
import { getPageQuery } from '@/utils/utils';
import { reloadAuthorized } from '@/utils/Authorized';
@@ -16,7 +16,7 @@ export default {
effects: {
*login({ payload }, { call, put }) {
const response = yield call(oauth2UsernameAuthenticate, payload);
const response = yield call(passportLogin, payload);
yield put({
type: 'changeLoginStatus',
payload: response,
@@ -28,7 +28,7 @@ export default {
if (response.code === 0) {
// 保存 token 到 localStorage发送请求的时候会自动取 token 放到 header
setLoginToken(response.data.token.accessToken, response.data.token.refreshToken);
setLoginToken(response.data.authorization.accessToken, response.data.authorization.refreshToken);
// 此处直接设置为 admin、和 user 角色,因为暂时不做服务控制前段 角色
setAuthority(['admin', 'user']);