commit
27239be92c
|
@ -4,6 +4,7 @@
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
grant_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThirdLoginParams {
|
export interface ThirdLoginParams {
|
||||||
|
@ -21,7 +22,7 @@ export interface RoleInfo {
|
||||||
*/
|
*/
|
||||||
export interface LoginResultModel {
|
export interface LoginResultModel {
|
||||||
userId: string | number;
|
userId: string | number;
|
||||||
token: string;
|
access_token: string;
|
||||||
role: RoleInfo;
|
role: RoleInfo;
|
||||||
userInfo?: any
|
userInfo?: any
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { PageEnum } from '/@/enums/pageEnum';
|
||||||
|
|
||||||
const { createErrorModal } = useMessage();
|
const { createErrorModal } = useMessage();
|
||||||
enum Api {
|
enum Api {
|
||||||
Login = '/sys/login',
|
Login = '/oauth2/token',
|
||||||
phoneLogin = '/sys/phoneLogin',
|
phoneLogin = '/sys/phoneLogin',
|
||||||
Logout = '/sys/logout',
|
Logout = '/sys/logout',
|
||||||
GetUserInfo = '/sys/user/getUserInfo',
|
GetUserInfo = '/sys/user/getUserInfo',
|
||||||
|
@ -52,8 +52,13 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
|
||||||
{
|
{
|
||||||
url: Api.Login,
|
url: Api.Login,
|
||||||
params,
|
params,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Authorization': 'Basic amVlY2ctY2xpZW50OnNlY3JldA=='
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
isTransformResponse: false,
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -134,14 +134,15 @@ export const useUserStore = defineStore({
|
||||||
): Promise<GetUserInfoModel | null> {
|
): Promise<GetUserInfoModel | null> {
|
||||||
try {
|
try {
|
||||||
const { goHome = true, mode, ...loginParams } = params;
|
const { goHome = true, mode, ...loginParams } = params;
|
||||||
|
loginParams.grant_type = 'password';
|
||||||
const data = await loginApi(loginParams, mode);
|
const data = await loginApi(loginParams, mode);
|
||||||
const { token, userInfo } = data;
|
const { access_token, userInfo } = data;
|
||||||
// save token
|
// save token
|
||||||
this.setToken(token);
|
this.setToken(access_token);
|
||||||
this.setTenant(userInfo.loginTenantId);
|
this.setTenant(userInfo.loginTenantId);
|
||||||
return this.afterLoginAction(goHome, data);
|
return this.afterLoginAction(goHome, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error.response.data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -142,7 +142,7 @@ const transform: AxiosTransform = {
|
||||||
let tenantId: string | number = getTenantId();
|
let tenantId: string | number = getTenantId();
|
||||||
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
|
||||||
// jwt token
|
// jwt token
|
||||||
config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : token;
|
config.headers.Authorization = options.authenticationScheme ? `${options.authenticationScheme} ${token}` : 'Bearer ' + token;
|
||||||
config.headers[ConfigEnum.TOKEN] = token;
|
config.headers[ConfigEnum.TOKEN] = token;
|
||||||
//--update-begin--author:liusq---date:20210831---for:将签名和时间戳,添加在请求接口 Header
|
//--update-begin--author:liusq---date:20210831---for:将签名和时间戳,添加在请求接口 Header
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@
|
||||||
username: data.account,
|
username: data.account,
|
||||||
captcha: data.inputCode,
|
captcha: data.inputCode,
|
||||||
checkKey: randCodeData.checkKey,
|
checkKey: randCodeData.checkKey,
|
||||||
|
grant_type: 'password',
|
||||||
mode: 'none', //不要默认的错误提示
|
mode: 'none', //不要默认的错误提示
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue