Compare commits

...

10 Commits

Author SHA1 Message Date
JEECG feb04114ef
Merge pull request #1269 from EightMonth/sas
sas兼容shiro处理
2024-06-20 16:09:05 +08:00
EightMonth 74c955924f sas兼容shiro处理 2024-05-23 10:49:37 +08:00
EightMonth 37a2093a87 sas兼容shiro处理 2024-05-22 18:43:06 +08:00
JEECG 21e156278f
Merge pull request #1016 from EightMonth/sas
基于sas打通三方登录
2024-01-17 13:56:40 +08:00
EightMonth 59fb423d36 打通三方登录 2024-01-16 19:50:33 +08:00
JEECG 10cfcd42c9
Merge pull request #998 from EightMonth/sas
切换为spring authorization server 登录,对应jeecg-boot springboot3_sas分支
2024-01-12 09:43:22 +08:00
EightMonth 52534d92c2 Merge branch 'master' into sas 2024-01-12 09:38:58 +08:00
EightMonth 4ed8270e7d 修改手机登录接口 2024-01-12 09:28:12 +08:00
JEECG 27239be92c
Merge pull request #975 from EightMonth/sas
sas认证升级
2024-01-07 22:56:06 +08:00
EightMonth 0ff3188e5f sas认证升级 2024-01-04 11:06:52 +08:00
5 changed files with 31 additions and 9 deletions

View File

@ -4,11 +4,13 @@
export interface LoginParams {
username: string;
password: string;
grant_type: string;
}
export interface ThirdLoginParams {
token: string;
thirdType: string;
grant_type: string;
}
export interface RoleInfo {

View File

@ -12,7 +12,7 @@ import { PageEnum } from '/@/enums/pageEnum';
const { createErrorModal } = useMessage();
enum Api {
Login = '/sys/login',
phoneLogin = '/sys/phoneLogin',
phoneLogin = '/oauth2/token',
Logout = '/sys/logout',
GetUserInfo = '/sys/user/getUserInfo',
// 获取系统权限
@ -35,7 +35,7 @@ enum Api {
//修改密码
passwordChange = '/sys/user/passwordChange',
//第三方登录
thirdLogin = '/sys/thirdLogin/getLoginUser',
thirdLogin = '/oauth2/token',
//第三方登录
getThirdCaptcha = '/sys/thirdSms',
//获取二维码信息
@ -52,6 +52,10 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
{
url: Api.Login,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic amVlY2ctY2xpZW50OnNlY3JldA=='
},
},
{
errorMessageMode: mode,
@ -67,8 +71,13 @@ export function phoneLoginApi(params: LoginParams, mode: ErrorMessageMode = 'mod
{
url: Api.phoneLogin,
params,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic amVlY2ctY2xpZW50OnNlY3JldA=='
},
},
{
isTransformResponse: false,
errorMessageMode: mode,
}
);
@ -162,12 +171,19 @@ export function thirdLogin(params, mode: ErrorMessageMode = 'modal') {
tenantId = params.tenantId;
}
//==========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,
}
);
}

View File

@ -134,6 +134,7 @@ export const useUserStore = defineStore({
): Promise<GetUserInfoModel | null> {
try {
const { goHome = true, mode, ...loginParams } = params;
loginParams.grant_type = 'password';
const data = await loginApi(loginParams, mode);
const { token, userInfo } = data;
// save token
@ -216,10 +217,11 @@ export const useUserStore = defineStore({
): Promise<GetUserInfoModel | null> {
try {
const { goHome = true, mode, ...loginParams } = params;
loginParams.grant_type = 'phone';
const data = await phoneLoginApi(loginParams, mode);
const { token } = data;
const { access_token } = data;
// save token
this.setToken(token);
this.setToken(access_token);
return this.afterLoginAction(goHome, data);
} catch (error) {
return Promise.reject(error);
@ -319,10 +321,11 @@ export const useUserStore = defineStore({
): Promise<any | null> {
try {
const { goHome = true, mode, ...ThirdLoginParams } = params;
ThirdLoginParams.grant_type = "social";
const data = await thirdLogin(ThirdLoginParams, mode);
const { token } = data;
const { access_token } = data;
// save token
this.setToken(token);
this.setToken(access_token);
return this.afterLoginAction(goHome, data);
} catch (error) {
return Promise.reject(error);

View File

@ -142,7 +142,7 @@ const transform: AxiosTransform = {
let tenantId: string | number = getTenantId();
if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
// 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;
//--update-begin--author:liusq---date:20210831---for:将签名和时间戳,添加在请求接口 Header

View File

@ -149,6 +149,7 @@
username: data.account,
captcha: data.inputCode,
checkKey: randCodeData.checkKey,
grant_type: 'password',
mode: 'none', //
})
);