Compare commits
10 Commits
master
...
v3.6.3_spr
Author | SHA1 | Date |
---|---|---|
![]() |
feb04114ef | |
![]() |
74c955924f | |
![]() |
37a2093a87 | |
![]() |
21e156278f | |
![]() |
59fb423d36 | |
![]() |
10cfcd42c9 | |
![]() |
52534d92c2 | |
![]() |
4ed8270e7d | |
![]() |
27239be92c | |
![]() |
0ff3188e5f |
|
@ -4,11 +4,13 @@
|
||||||
export interface LoginParams {
|
export interface LoginParams {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
grant_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ThirdLoginParams {
|
export interface ThirdLoginParams {
|
||||||
token: string;
|
token: string;
|
||||||
thirdType: string;
|
thirdType: string;
|
||||||
|
grant_type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RoleInfo {
|
export interface RoleInfo {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { PageEnum } from '/@/enums/pageEnum';
|
||||||
const { createErrorModal } = useMessage();
|
const { createErrorModal } = useMessage();
|
||||||
enum Api {
|
enum Api {
|
||||||
Login = '/sys/login',
|
Login = '/sys/login',
|
||||||
phoneLogin = '/sys/phoneLogin',
|
phoneLogin = '/oauth2/token',
|
||||||
Logout = '/sys/logout',
|
Logout = '/sys/logout',
|
||||||
GetUserInfo = '/sys/user/getUserInfo',
|
GetUserInfo = '/sys/user/getUserInfo',
|
||||||
// 获取系统权限
|
// 获取系统权限
|
||||||
|
@ -35,7 +35,7 @@ enum Api {
|
||||||
//修改密码
|
//修改密码
|
||||||
passwordChange = '/sys/user/passwordChange',
|
passwordChange = '/sys/user/passwordChange',
|
||||||
//第三方登录
|
//第三方登录
|
||||||
thirdLogin = '/sys/thirdLogin/getLoginUser',
|
thirdLogin = '/oauth2/token',
|
||||||
//第三方登录
|
//第三方登录
|
||||||
getThirdCaptcha = '/sys/thirdSms',
|
getThirdCaptcha = '/sys/thirdSms',
|
||||||
//获取二维码信息
|
//获取二维码信息
|
||||||
|
@ -52,6 +52,10 @@ 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=='
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
|
@ -67,8 +71,13 @@ export function phoneLoginApi(params: LoginParams, mode: ErrorMessageMode = 'mod
|
||||||
{
|
{
|
||||||
url: Api.phoneLogin,
|
url: Api.phoneLogin,
|
||||||
params,
|
params,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Authorization': 'Basic amVlY2ctY2xpZW50OnNlY3JldA=='
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
isTransformResponse: false,
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -162,12 +171,19 @@ export function thirdLogin(params, mode: ErrorMessageMode = 'modal') {
|
||||||
tenantId = params.tenantId;
|
tenantId = params.tenantId;
|
||||||
}
|
}
|
||||||
//==========end 第三方登录/auth2登录需要传递租户id===========
|
//==========end 第三方登录/auth2登录需要传递租户id===========
|
||||||
return defHttp.get<LoginResultModel>(
|
return defHttp.post<LoginResultModel>(
|
||||||
{
|
{
|
||||||
url: `${Api.thirdLogin}/${params.token}/${params.thirdType}/${tenantId}`,
|
url: `${Api.thirdLogin}`,
|
||||||
|
params,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
'Authorization': 'Basic amVlY2ctY2xpZW50OnNlY3JldA=='
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
isTransformResponse: false,
|
||||||
errorMessageMode: mode,
|
errorMessageMode: mode,
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,7 @@ 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 { token, userInfo } = data;
|
||||||
// save token
|
// save token
|
||||||
|
@ -216,10 +217,11 @@ 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 = 'phone';
|
||||||
const data = await phoneLoginApi(loginParams, mode);
|
const data = await phoneLoginApi(loginParams, mode);
|
||||||
const { token } = data;
|
const { access_token } = data;
|
||||||
// save token
|
// save token
|
||||||
this.setToken(token);
|
this.setToken(access_token);
|
||||||
return this.afterLoginAction(goHome, data);
|
return this.afterLoginAction(goHome, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
|
@ -319,10 +321,11 @@ export const useUserStore = defineStore({
|
||||||
): Promise<any | null> {
|
): Promise<any | null> {
|
||||||
try {
|
try {
|
||||||
const { goHome = true, mode, ...ThirdLoginParams } = params;
|
const { goHome = true, mode, ...ThirdLoginParams } = params;
|
||||||
|
ThirdLoginParams.grant_type = "social";
|
||||||
const data = await thirdLogin(ThirdLoginParams, mode);
|
const data = await thirdLogin(ThirdLoginParams, mode);
|
||||||
const { token } = data;
|
const { access_token } = data;
|
||||||
// save token
|
// save token
|
||||||
this.setToken(token);
|
this.setToken(access_token);
|
||||||
return this.afterLoginAction(goHome, data);
|
return this.afterLoginAction(goHome, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
|
|
|
@ -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