1. admin-web 接入新的登陆接入
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { routerRedux } from 'dva/router';
|
||||
import { stringify } from 'qs';
|
||||
import { fakeAccountLogin, getFakeCaptcha } from '@/services/api';
|
||||
import { getFakeCaptcha } from '@/services/api';
|
||||
import { usernameAuthenticate } from '@/services/system';
|
||||
import { setAuthority } from '@/utils/authority';
|
||||
import { getPageQuery } from '@/utils/utils';
|
||||
import { reloadAuthorized } from '@/utils/Authorized';
|
||||
@@ -15,7 +16,7 @@ export default {
|
||||
|
||||
effects: {
|
||||
*login({ payload }, { call, put }) {
|
||||
const response = yield call(fakeAccountLogin, payload);
|
||||
const response = yield call(usernameAuthenticate, payload);
|
||||
yield put({
|
||||
type: 'changeLoginStatus',
|
||||
payload: response,
|
||||
@@ -23,6 +24,8 @@ export default {
|
||||
|
||||
yield put(routerRedux.replace('/'));
|
||||
|
||||
debugger;
|
||||
|
||||
// Login successfully
|
||||
if (response.code === 0) {
|
||||
|
||||
|
||||
10
admin-web/src/services/system.js
Normal file
10
admin-web/src/services/system.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { stringify } from '@/utils/request.qs';
|
||||
import request from '@/utils/request';
|
||||
|
||||
|
||||
export async function usernameAuthenticate(params) {
|
||||
return request(`/system-api/admins/oauth2/username-authenticate?${stringify(params)}`, {
|
||||
method: 'POST',
|
||||
body: {},
|
||||
});
|
||||
}
|
||||
@@ -138,7 +138,7 @@ export default function request(url, option) {
|
||||
// 将登陆的 accessToken 放到 header
|
||||
const loginToken = getLoginToken();
|
||||
if (loginToken && loginToken.accessToken
|
||||
&& url.indexOf('/passport/login') === -1) { // TODO 芋艿,临时这么加,可能不是很优雅
|
||||
&& url.indexOf('/system-api/admins/oauth2/username-authenticate') === -1) { // TODO 芋艿,临时这么加,可能不是很优雅
|
||||
const headers = {
|
||||
...newOptions.headers,
|
||||
Authorization: `Bearer ${loginToken.accessToken}`,
|
||||
|
||||
Reference in New Issue
Block a user