mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 09:03:53 +00:00
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
import { GET, POST, PUT } from '@/web/common/api/request';
|
|
import { hashStr } from '@fastgpt/global/common/string/tools';
|
|
import type { ResLogin } from '@/global/support/api/userRes.d';
|
|
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
|
import { UserUpdateParams } from '@/types/user';
|
|
import { UserType } from '@fastgpt/global/support/user/type.d';
|
|
import type {
|
|
FastLoginProps,
|
|
OauthLoginProps,
|
|
PostLoginProps
|
|
} from '@fastgpt/global/support/user/api.d';
|
|
import { GetWXLoginQRResponse } from '@fastgpt/global/support/user/login/api.d';
|
|
|
|
export const sendAuthCode = (data: {
|
|
username: string;
|
|
type: `${UserAuthTypeEnum}`;
|
|
googleToken: string;
|
|
captcha: string;
|
|
}) => POST(`/proApi/support/user/inform/sendAuthCode`, data);
|
|
|
|
export const getTokenLogin = () =>
|
|
GET<UserType>('/support/user/account/tokenLogin', {}, { maxQuantity: 1 });
|
|
export const oauthLogin = (params: OauthLoginProps) =>
|
|
POST<ResLogin>('/proApi/support/user/account/login/oauth', params);
|
|
export const postFastLogin = (params: FastLoginProps) =>
|
|
POST<ResLogin>('/proApi/support/user/account/login/fastLogin', params);
|
|
export const ssoLogin = (params: any) => GET<ResLogin>('/proApi/support/user/account/sso', params);
|
|
|
|
export const postRegister = ({
|
|
username,
|
|
password,
|
|
code,
|
|
inviterId,
|
|
bd_vid
|
|
}: {
|
|
username: string;
|
|
code: string;
|
|
password: string;
|
|
inviterId?: string;
|
|
bd_vid?: string;
|
|
}) =>
|
|
POST<ResLogin>(`/proApi/support/user/account/register/emailAndPhone`, {
|
|
username,
|
|
code,
|
|
inviterId,
|
|
bd_vid,
|
|
password: hashStr(password)
|
|
});
|
|
|
|
export const postFindPassword = ({
|
|
username,
|
|
code,
|
|
password
|
|
}: {
|
|
username: string;
|
|
code: string;
|
|
password: string;
|
|
}) =>
|
|
POST<ResLogin>(`/proApi/support/user/account/password/updateByCode`, {
|
|
username,
|
|
code,
|
|
password: hashStr(password)
|
|
});
|
|
|
|
export const updatePasswordByOld = ({ oldPsw, newPsw }: { oldPsw: string; newPsw: string }) =>
|
|
POST('/support/user/account/updatePasswordByOld', {
|
|
oldPsw: hashStr(oldPsw),
|
|
newPsw: hashStr(newPsw)
|
|
});
|
|
|
|
export const updateNotificationAccount = (data: { account: string; verifyCode: string }) =>
|
|
PUT('/proApi/support/user/team/updateNotificationAccount', data);
|
|
|
|
export const postLogin = ({ password, ...props }: PostLoginProps) =>
|
|
POST<ResLogin>('/support/user/account/loginByPassword', {
|
|
...props,
|
|
password: hashStr(password)
|
|
});
|
|
|
|
export const loginOut = () => GET('/support/user/account/loginout');
|
|
|
|
export const putUserInfo = (data: UserUpdateParams) => PUT('/support/user/account/update', data);
|
|
|
|
export const getWXLoginQR = () =>
|
|
GET<GetWXLoginQRResponse>('/proApi/support/user/account/login/wx/getQR');
|
|
|
|
export const getWXLoginResult = (code: string) =>
|
|
GET<ResLogin>(`/proApi/support/user/account/login/wx/getResult`, { code });
|
|
|
|
export const getCaptchaPic = (username: string) =>
|
|
GET<{
|
|
captchaImage: string;
|
|
}>('/proApi/support/user/account/captcha/getImgCaptcha', { username });
|