mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 20:27:45 +00:00

Co-authored-by: Mufei <327958099@qq.com> Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
81 lines
2.4 KiB
TypeScript
81 lines
2.4 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;
|
|
}) => 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 postRegister = ({
|
|
username,
|
|
password,
|
|
code,
|
|
inviterId
|
|
}: {
|
|
username: string;
|
|
code: string;
|
|
password: string;
|
|
inviterId?: string;
|
|
}) =>
|
|
POST<ResLogin>(`/proApi/support/user/account/register/emailAndPhone`, {
|
|
username,
|
|
code,
|
|
inviterId,
|
|
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 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 });
|