feat: auth api

pull/48/MERGE
xingyu 2024-11-18 19:00:16 +08:00
parent 98a91e1cb2
commit 91e1ee7ae4
1 changed files with 51 additions and 15 deletions

View File

@ -23,6 +23,15 @@ export namespace AuthApi {
data: string; data: string;
status: number; status: number;
} }
export interface SmsCodeVO {
mobile: string;
scene: number;
}
export interface SmsLoginVO {
mobile: string;
code: string;
}
} }
/** /**
@ -36,11 +45,8 @@ export function loginApi(data: AuthApi.LoginParams) {
* accessToken * accessToken
*/ */
export function refreshTokenApi() { export function refreshTokenApi() {
return baseRequestClient.post<AuthApi.LoginResult>( return requestClient.post<AuthApi.LoginResult>(
`/system/auth/refresh-token?refreshToken=${getRefreshToken()}`, `/system/auth/refresh-token?refreshToken=${getRefreshToken()}`,
{
withCredentials: true,
},
); );
} }
@ -68,30 +74,60 @@ export function getTenantByWebsite(website: string) {
* 退 * 退
*/ */
export function logoutApi() { export function logoutApi() {
return baseRequestClient.post('/system/auth/logout', { return requestClient.post('/system/auth/logout');
withCredentials: true, }
/**
*
*/
export function getUserInfo() {
return requestClient.get<YudaoUserInfo>('/system/auth/get-permission-info');
}
/**
*
*/
export function sendSmsCode(data: AuthApi.SmsCodeVO) {
return requestClient.post('/system/auth/send-sms-code', data);
}
/**
*
*/
export function smsLogin(data: AuthApi.SmsLoginVO) {
return requestClient.post('/system/auth/sms-login', data);
}
/**
* 使 code
*/
export function socialLogin(type: string, code: string, state: string) {
return requestClient.post('/system/auth/social-login', {
type,
code,
state,
}); });
} }
// 获取用户权限信息 /**
export function getUserInfo() { *
return requestClient.get<YudaoUserInfo>('/system/auth/get-permission-info'); */
export function socialAuthRedirect(type: number, redirectUri: string) {
return requestClient.get(
`/system/auth/social-auth-redirect?type=${type}&redirectUri=${redirectUri}`,
);
} }
/** /**
* token * token
*/ */
export function getCaptcha(data: any) { export function getCaptcha(data: any) {
return baseRequestClient.post('/system/captcha/get', data, { return baseRequestClient.post('/system/captcha/get', data);
// isReturnNativeResponse: true,
});
} }
/** /**
* *
*/ */
export function checkCaptcha(data: any) { export function checkCaptcha(data: any) {
return baseRequestClient.post('/system/captcha/check', data, { return baseRequestClient.post('/system/captcha/check', data);
// isReturnNativeResponse: true,
});
} }