mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-07 01:02:55 +08:00
fix: login secret (#6635)
* fix: login secret * lock * env template * fix: ts * fix: ts * fix: ts
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import type { UserType } from '@fastgpt/global/support/user/type';
|
||||
import type { PromotionRecordSchema } from '@fastgpt/global/support/activity/type';
|
||||
export interface LoginSuccessResponse {
|
||||
user: UserType;
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface PromotionRecordType {
|
||||
_id: PromotionRecordSchema['_id'];
|
||||
|
||||
@@ -4,16 +4,16 @@ import { useForm } from 'react-hook-form';
|
||||
import { LoginPageTypeEnum } from '@/web/support/user/login/constants';
|
||||
import { postFindPassword } from '@/web/support/user/api';
|
||||
import { useSendCode } from '@/web/support/user/hooks/useSendCode';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useRequest } from '@fastgpt/web/hooks/useRequest';
|
||||
import { checkPasswordRule } from '@fastgpt/global/common/string/password';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
interface Props {
|
||||
setPageType: Dispatch<`${LoginPageTypeEnum}`>;
|
||||
loginSuccess: (e: LoginSuccessResponse) => void;
|
||||
loginSuccess: (e: LoginSuccessResponseType) => void;
|
||||
}
|
||||
|
||||
interface RegisterType {
|
||||
|
||||
@@ -3,7 +3,6 @@ import { FormControl, Flex, Input, Button, Box } from '@chakra-ui/react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { LoginPageTypeEnum } from '@/web/support/user/login/constants';
|
||||
import { postLogin, getPreLogin } from '@/web/support/user/api';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -15,10 +14,11 @@ import { UserErrEnum } from '@fastgpt/global/common/error/code/user';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useMount } from 'ahooks';
|
||||
import type { LangEnum } from '@fastgpt/global/common/i18n/type';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
interface Props {
|
||||
setPageType: Dispatch<`${LoginPageTypeEnum}`>;
|
||||
loginSuccess: (e: LoginSuccessResponse) => void;
|
||||
loginSuccess: (e: LoginSuccessResponseType) => void;
|
||||
}
|
||||
|
||||
interface LoginFormType {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { type Dispatch } from 'react';
|
||||
import { LoginPageTypeEnum } from '@/web/support/user/login/constants';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { Box, Center, Flex, Link } from '@chakra-ui/react';
|
||||
import { Box, Center } from '@chakra-ui/react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getWXLoginQR, getWXLoginResult } from '@/web/support/user/api';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
@@ -18,12 +17,12 @@ import {
|
||||
removeFastGPTSem,
|
||||
getInviterId
|
||||
} from '@/web/support/marketing/utils';
|
||||
import { getDocPath } from '@/web/common/system/doc';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import PolicyTip from './PolicyTip';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
interface Props {
|
||||
loginSuccess: (e: LoginSuccessResponse) => void;
|
||||
loginSuccess: (e: LoginSuccessResponseType) => void;
|
||||
setPageType: Dispatch<`${LoginPageTypeEnum}`>;
|
||||
}
|
||||
|
||||
@@ -55,7 +54,7 @@ const WechatForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
{
|
||||
refetchInterval: 3 * 1000,
|
||||
enabled: !!wechatInfo?.code,
|
||||
onSuccess(data: LoginSuccessResponse | undefined) {
|
||||
onSuccess(data: LoginSuccessResponseType | undefined) {
|
||||
if (data) {
|
||||
removeFastGPTSem();
|
||||
loginSuccess(data);
|
||||
|
||||
@@ -4,10 +4,10 @@ import { LoginContainer } from '@/pageComponents/login';
|
||||
import I18nLngSelector from '@/components/Select/I18nLngSelector';
|
||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { type LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
type LoginModalProps = {
|
||||
onSuccess: (e: LoginSuccessResponse) => any;
|
||||
onSuccess: (e: LoginSuccessResponseType) => any;
|
||||
};
|
||||
|
||||
const LoginModal = ({ onSuccess }: LoginModalProps) => {
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useForm } from 'react-hook-form';
|
||||
import { LoginPageTypeEnum } from '@/web/support/user/login/constants';
|
||||
import { postRegister } from '@/web/support/user/api';
|
||||
import { useSendCode } from '@/web/support/user/hooks/useSendCode';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
@@ -18,9 +17,10 @@ import {
|
||||
removeFastGPTSem
|
||||
} from '@/web/support/marketing/utils';
|
||||
import { checkPasswordRule } from '@fastgpt/global/common/string/password';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
interface Props {
|
||||
loginSuccess: (e: LoginSuccessResponse) => void;
|
||||
loginSuccess: (e: LoginSuccessResponseType) => void;
|
||||
setPageType: Dispatch<`${LoginPageTypeEnum}`>;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
} from '@chakra-ui/react';
|
||||
import { LoginPageTypeEnum } from '@/web/support/user/login/constants';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useChatStore } from '@/web/core/chat/context/useChatStore';
|
||||
import dynamic from 'next/dynamic';
|
||||
import Script from 'next/script';
|
||||
@@ -20,6 +19,7 @@ import { useTranslation } from 'next-i18next';
|
||||
import LoginForm from '@/pageComponents/login/LoginForm/LoginForm';
|
||||
import { GET } from '@/web/common/api/request';
|
||||
import { getDocPath } from '@/web/common/system/doc';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
const RegisterForm = dynamic(() => import('@/pageComponents/login/RegisterForm'));
|
||||
const ForgetPasswordForm = dynamic(() => import('@/pageComponents/login/ForgetPasswordForm'));
|
||||
@@ -184,7 +184,7 @@ export const LoginContainer = ({
|
||||
onSuccess
|
||||
}: {
|
||||
children?: React.ReactNode;
|
||||
onSuccess: (res: LoginSuccessResponse) => void;
|
||||
onSuccess: (res: LoginSuccessResponseType) => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { feConfigs } = useSystemStore();
|
||||
@@ -195,7 +195,7 @@ export const LoginContainer = ({
|
||||
|
||||
// login success handler
|
||||
const loginSuccess = useCallback(
|
||||
(res: LoginSuccessResponse) => {
|
||||
(res: LoginSuccessResponseType) => {
|
||||
onSuccess?.(res);
|
||||
},
|
||||
[onSuccess]
|
||||
|
||||
@@ -3,17 +3,12 @@ import { NextAPI } from '@/service/middleware/entry';
|
||||
import { checkPswExpired } from '@/service/support/user/account/password';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { MongoUser } from '@fastgpt/service/support/user/schema';
|
||||
|
||||
export type getTimeQuery = {};
|
||||
|
||||
export type getTimeBody = {};
|
||||
|
||||
export type getTimeResponse = boolean;
|
||||
import type { CheckPswExpiredResponseType } from '@fastgpt/global/openapi/support/user/account/password/api';
|
||||
|
||||
async function handler(
|
||||
req: ApiRequestProps<getTimeBody, getTimeQuery>,
|
||||
res: ApiResponseType<getTimeResponse>
|
||||
): Promise<getTimeResponse> {
|
||||
req: ApiRequestProps,
|
||||
res: ApiResponseType
|
||||
): Promise<CheckPswExpiredResponseType> {
|
||||
const { userId } = await authCert({ req, authToken: true });
|
||||
|
||||
const user = await MongoUser.findById(userId, 'passwordUpdateTime');
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { MongoUser } from '@fastgpt/service/support/user/schema';
|
||||
import { getUserDetail } from '@fastgpt/service/support/user/controller';
|
||||
import type { PostLoginProps } from '@fastgpt/global/support/user/api';
|
||||
import { UserStatusEnum } from '@fastgpt/global/support/user/constant';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { useIPFrequencyLimit } from '@fastgpt/service/common/middle/reqFrequencyLimit';
|
||||
import { pushTrack } from '@fastgpt/service/common/middle/tracks/utils';
|
||||
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
|
||||
import { UserErrEnum } from '@fastgpt/global/common/error/code/user';
|
||||
import { addAuditLog } from '@fastgpt/service/support/user/audit/util';
|
||||
import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants';
|
||||
@@ -16,13 +13,18 @@ import { createUserSession } from '@fastgpt/service/support/user/session';
|
||||
import requestIp from 'request-ip';
|
||||
import { setCookie } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { UserError } from '@fastgpt/global/common/error/utils';
|
||||
import {
|
||||
LoginByPasswordBodySchema,
|
||||
type LoginByPasswordBodyType,
|
||||
type LoginSuccessResponseType
|
||||
} from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
|
||||
|
||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { username, password, code, language = 'zh-CN' } = req.body as PostLoginProps;
|
||||
|
||||
if (!username || !password || !code) {
|
||||
return Promise.reject(CommonErrEnum.invalidParams);
|
||||
}
|
||||
async function handler(
|
||||
req: ApiRequestProps<LoginByPasswordBodyType>,
|
||||
res: ApiResponseType
|
||||
): Promise<LoginSuccessResponseType> {
|
||||
const { username, password, code, language } = LoginByPasswordBodySchema.parse(req.body);
|
||||
|
||||
// Auth prelogin code
|
||||
await authCode({
|
||||
|
||||
@@ -4,25 +4,17 @@ import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||
import { addSeconds } from 'date-fns';
|
||||
import { addAuthCode } from '@fastgpt/service/support/user/auth/controller';
|
||||
import { UserError } from '@fastgpt/global/common/error/utils';
|
||||
|
||||
export type preLoginQuery = {
|
||||
username: string;
|
||||
};
|
||||
|
||||
export type preLoginBody = {};
|
||||
|
||||
export type preLoginResponse = { code: string };
|
||||
import {
|
||||
PreLoginQuerySchema,
|
||||
type PreLoginQueryType,
|
||||
type PreLoginResponseType
|
||||
} from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
async function handler(
|
||||
req: ApiRequestProps<preLoginBody, preLoginQuery>,
|
||||
req: ApiRequestProps<{}, PreLoginQueryType>,
|
||||
res: ApiResponseType<any>
|
||||
): Promise<preLoginResponse> {
|
||||
const { username } = req.query;
|
||||
|
||||
if (!username) {
|
||||
return Promise.reject(new UserError('username is required'));
|
||||
}
|
||||
): Promise<PreLoginResponseType> {
|
||||
const { username } = PreLoginQuerySchema.parse(req.query);
|
||||
|
||||
const code = getNanoid(6);
|
||||
|
||||
|
||||
@@ -5,20 +5,16 @@ import { NextAPI } from '@/service/middleware/entry';
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
import { checkPswExpired } from '@/service/support/user/account/password';
|
||||
import { delUserAllSession } from '@fastgpt/service/support/user/session';
|
||||
|
||||
export type resetExpiredPswQuery = {};
|
||||
|
||||
export type resetExpiredPswBody = {
|
||||
newPsw: string;
|
||||
};
|
||||
|
||||
export type resetExpiredPswResponse = {};
|
||||
import {
|
||||
ResetExpiredPswBodySchema,
|
||||
type ResetExpiredPswResponseType
|
||||
} from '@fastgpt/global/openapi/support/user/account/password/api';
|
||||
|
||||
async function resetExpiredPswHandler(
|
||||
req: ApiRequestProps<resetExpiredPswBody, resetExpiredPswQuery>,
|
||||
res: ApiResponseType<resetExpiredPswResponse>
|
||||
): Promise<resetExpiredPswResponse> {
|
||||
const newPsw = req.body.newPsw;
|
||||
req: ApiRequestProps,
|
||||
res: ApiResponseType
|
||||
): Promise<ResetExpiredPswResponseType> {
|
||||
const { newPsw } = ResetExpiredPswBodySchema.parse(req.body);
|
||||
const { userId, sessionId } = await authCert({ req, authToken: true });
|
||||
const user = await MongoUser.findById(userId, 'passwordUpdateTime').lean();
|
||||
|
||||
|
||||
@@ -2,17 +2,10 @@ import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { getUserDetail } from '@fastgpt/service/support/user/controller';
|
||||
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
|
||||
import { NextAPI } from '@/service/middleware/entry';
|
||||
import { type UserType } from '@fastgpt/global/support/user/type';
|
||||
import { pushTrack } from '@fastgpt/service/common/middle/tracks/utils';
|
||||
import type { UserType } from '@fastgpt/global/support/user/type';
|
||||
|
||||
export type TokenLoginQuery = {};
|
||||
export type TokenLoginBody = {};
|
||||
export type TokenLoginResponse = UserType;
|
||||
|
||||
async function handler(
|
||||
req: ApiRequestProps<TokenLoginBody, TokenLoginQuery>,
|
||||
_res: ApiResponseType<any>
|
||||
): Promise<TokenLoginResponse> {
|
||||
async function handler(req: ApiRequestProps, _res: ApiResponseType): Promise<UserType> {
|
||||
const { tmbId, userId, teamId } = await authCert({ req, authToken: true });
|
||||
const user = await getUserDetail({ tmbId });
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { authCert } from '@fastgpt/service/support/permission/auth/common';
|
||||
import { MongoUser } from '@fastgpt/service/support/user/schema';
|
||||
|
||||
@@ -8,12 +7,18 @@ import { NextAPI } from '@/service/middleware/entry';
|
||||
import { addAuditLog } from '@fastgpt/service/support/user/audit/util';
|
||||
import { AuditEventEnum } from '@fastgpt/global/support/user/audit/constants';
|
||||
import { delUserAllSession } from '@fastgpt/service/support/user/session';
|
||||
async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
|
||||
const { oldPsw, newPsw } = req.body as { oldPsw: string; newPsw: string };
|
||||
import {
|
||||
UpdatePasswordByOldBodySchema,
|
||||
type UpdatePasswordByOldBodyType,
|
||||
type UpdatePasswordByOldResponseType
|
||||
} from '@fastgpt/global/openapi/support/user/account/password/api';
|
||||
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
|
||||
|
||||
if (!oldPsw || !newPsw) {
|
||||
return Promise.reject('Params is missing');
|
||||
}
|
||||
async function handler(
|
||||
req: ApiRequestProps<UpdatePasswordByOldBodyType>,
|
||||
res: ApiResponseType<any>
|
||||
): Promise<UpdatePasswordByOldResponseType> {
|
||||
const { oldPsw, newPsw } = UpdatePasswordByOldBodySchema.parse(req.body);
|
||||
|
||||
const { tmbId, teamId, sessionId } = await authCert({ req, authToken: true });
|
||||
const tmb = await MongoTeamMember.findById(tmbId);
|
||||
|
||||
@@ -23,10 +23,10 @@ import { ChatPageContext, ChatPageContextProvider } from '@/web/core/chat/contex
|
||||
import ChatTeamApp from '@/pageComponents/chat/ChatTeamApp';
|
||||
import ChatFavouriteApp from '@/pageComponents/chat/ChatFavouriteApp';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { MongoOutLink } from '@fastgpt/service/support/outLink/schema';
|
||||
import { getLogger, LogCategories } from '@fastgpt/service/common/logger';
|
||||
import { PublishChannelEnum } from '@fastgpt/global/support/outLink/constant';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
const logger = getLogger(LogCategories.MODULE.CHAT.ITEM);
|
||||
|
||||
@@ -121,7 +121,7 @@ const ChatContent = (props: ChatPageProps) => {
|
||||
}, [appId, chatId]);
|
||||
|
||||
const loginSuccess = useCallback(
|
||||
async (res: LoginSuccessResponse) => {
|
||||
async (res: LoginSuccessResponseType) => {
|
||||
setUserInfo(res.user);
|
||||
},
|
||||
[setUserInfo]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { clearToken } from '@/web/support/user/auth';
|
||||
import { postFastLogin } from '@/web/support/user/api';
|
||||
@@ -10,6 +9,7 @@ import { serviceSideProps } from '@/web/common/i18n/utils';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { validateRedirectUrl } from '@/web/common/utils/uri';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
const FastLogin = ({
|
||||
code,
|
||||
@@ -25,7 +25,7 @@ const FastLogin = ({
|
||||
const { toast } = useToast();
|
||||
const { t } = useTranslation();
|
||||
const loginSuccess = useCallback(
|
||||
(res: LoginSuccessResponse) => {
|
||||
(res: LoginSuccessResponseType) => {
|
||||
setUserInfo(res.user);
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -5,12 +5,12 @@ import { clearToken } from '@/web/support/user/auth';
|
||||
import { useMount } from 'ahooks';
|
||||
import LoginModal from '@/pageComponents/login/LoginModal';
|
||||
import { postAcceptInvitationLink } from '@/web/support/user/team/api';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { subRoute } from '@fastgpt/web/common/system/utils';
|
||||
import { validateRedirectUrl } from '@/web/common/utils/uri';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
const Login = () => {
|
||||
const router = useRouter();
|
||||
@@ -20,7 +20,7 @@ const Login = () => {
|
||||
const { setUserInfo } = useUserStore();
|
||||
|
||||
const loginSuccess = useCallback(
|
||||
async (res: LoginSuccessResponse) => {
|
||||
async (res: LoginSuccessResponseType) => {
|
||||
setUserInfo(res.user);
|
||||
|
||||
const decodeLastRoute = validateRedirectUrl(lastRoute);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { useCallback, useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||
import { clearToken } from '@/web/support/user/auth';
|
||||
import { oauthLogin } from '@/web/support/user/api';
|
||||
@@ -23,6 +22,7 @@ import { postAcceptInvitationLink } from '@/web/support/user/team/api';
|
||||
import { retryFn } from '@fastgpt/global/common/system/utils';
|
||||
import type { LangEnum } from '@fastgpt/global/common/i18n/type';
|
||||
import { validateRedirectUrl } from '@/web/common/utils/uri';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
let isOauthLogging = false;
|
||||
|
||||
@@ -40,7 +40,7 @@ const provider = () => {
|
||||
const errorRedirectPage = lastRoute.startsWith('/chat') ? lastRoute : '/login';
|
||||
|
||||
const loginSuccess = useCallback(
|
||||
async (res: LoginSuccessResponse) => {
|
||||
async (res: LoginSuccessResponseType) => {
|
||||
const decodeLastRoute = validateRedirectUrl(lastRoute);
|
||||
setUserInfo(res.user);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
} from '@fastgpt/global/core/ai/provider';
|
||||
import { getMyModels, getOperationalAd } from './api';
|
||||
|
||||
type LoginStoreType = { provider: `${OAuthEnum}`; lastRoute: string; state: string };
|
||||
type LoginStoreType = { provider: OAuthEnum; lastRoute: string; state: string };
|
||||
|
||||
export type NotSufficientModalType =
|
||||
| TeamErrEnum.datasetSizeNotEnough
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import { GET, POST, PUT } from '@/web/common/api/request';
|
||||
import { hashStr } from '@fastgpt/global/common/string/tools';
|
||||
import type { LoginSuccessResponse } from '@/global/support/api/userRes';
|
||||
import type { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
||||
import type { UserUpdateParams } from '@/types/user';
|
||||
import type { UserType } from '@fastgpt/global/support/user/type';
|
||||
import type { SearchResult } from '@fastgpt/global/support/user/api';
|
||||
import type {
|
||||
FastLoginProps,
|
||||
OauthLoginProps,
|
||||
PostLoginProps,
|
||||
SearchResult
|
||||
} from '@fastgpt/global/support/user/api';
|
||||
import type {
|
||||
AccountRegisterBody,
|
||||
GetWXLoginQRResponse
|
||||
} from '@fastgpt/global/support/user/login/api';
|
||||
import type { preLoginResponse } from '@/pages/api/support/user/account/preLogin';
|
||||
import type { WxLoginProps } from '@fastgpt/global/support/user/api';
|
||||
PreLoginResponseType,
|
||||
LoginByPasswordBodyType,
|
||||
OauthLoginBodyType,
|
||||
FastLoginBodyType,
|
||||
WxLoginBodyType,
|
||||
GetWXLoginQRResponseType
|
||||
} from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
import type { UpdatePasswordByOldBodyType } from '@fastgpt/global/openapi/support/user/account/password/api';
|
||||
import type { AccountRegisterBodyType } from '@fastgpt/global/openapi/support/user/account/register/api';
|
||||
import type { LangEnum } from '@fastgpt/global/common/i18n/type';
|
||||
import type { LoginSuccessResponseType } from '@fastgpt/global/openapi/support/user/account/login/api';
|
||||
|
||||
/* ===== Auth code ===== */
|
||||
export const sendAuthCode = (data: {
|
||||
username: string;
|
||||
type: `${UserAuthTypeEnum}`;
|
||||
@@ -25,16 +25,37 @@ export const sendAuthCode = (data: {
|
||||
captcha: string;
|
||||
lang: `${LangEnum}`;
|
||||
}) => POST(`/proApi/support/user/inform/sendAuthCode`, data);
|
||||
export const getCaptchaPic = (username: string) =>
|
||||
GET<{
|
||||
captchaImage: string;
|
||||
}>('/proApi/support/user/account/captcha/getImgCaptcha', { username });
|
||||
|
||||
/* ===== login ===== */
|
||||
export const getPreLogin = (username: string) =>
|
||||
GET<PreLoginResponseType>('/support/user/account/preLogin', { username });
|
||||
|
||||
export const getTokenLogin = () =>
|
||||
GET<UserType>('/support/user/account/tokenLogin', {}, { maxQuantity: 1 });
|
||||
export const oauthLogin = (params: OauthLoginProps) =>
|
||||
POST<LoginSuccessResponse>('/proApi/support/user/account/login/oauth', params);
|
||||
export const postFastLogin = (params: FastLoginProps) =>
|
||||
POST<LoginSuccessResponse>('/proApi/support/user/account/login/fastLogin', params);
|
||||
export const oauthLogin = (params: OauthLoginBodyType) =>
|
||||
POST<LoginSuccessResponseType>('/proApi/support/user/account/login/oauth', params);
|
||||
export const postFastLogin = (params: FastLoginBodyType) =>
|
||||
POST<LoginSuccessResponseType>('/proApi/support/user/account/login/fastLogin', params);
|
||||
export const ssoLogin = (params: any) =>
|
||||
GET<LoginSuccessResponse>('/proApi/support/user/account/sso', params);
|
||||
GET<LoginSuccessResponseType>('/proApi/support/user/account/sso', params);
|
||||
export const postLogin = ({ password, ...props }: LoginByPasswordBodyType) =>
|
||||
POST<LoginSuccessResponseType>('/support/user/account/loginByPassword', {
|
||||
...props,
|
||||
password: hashStr(password)
|
||||
});
|
||||
// wx login
|
||||
export const getWXLoginQR = () =>
|
||||
GET<GetWXLoginQRResponseType>('/proApi/support/user/account/login/wx/getQR');
|
||||
|
||||
export const getWXLoginResult = (params: WxLoginBodyType) =>
|
||||
POST<LoginSuccessResponseType>(`/proApi/support/user/account/login/wx/getResult`, params);
|
||||
export const loginOut = () => GET('/support/user/account/loginout');
|
||||
|
||||
/* ===== register ===== */
|
||||
export const postRegister = ({
|
||||
username,
|
||||
password,
|
||||
@@ -43,8 +64,8 @@ export const postRegister = ({
|
||||
bd_vid,
|
||||
msclkid,
|
||||
fastgpt_sem
|
||||
}: AccountRegisterBody) =>
|
||||
POST<LoginSuccessResponse>(`/proApi/support/user/account/register/emailAndPhone`, {
|
||||
}: AccountRegisterBodyType) =>
|
||||
POST<LoginSuccessResponseType>(`/proApi/support/user/account/register/emailAndPhone`, {
|
||||
username,
|
||||
code,
|
||||
inviterId,
|
||||
@@ -54,6 +75,7 @@ export const postRegister = ({
|
||||
password: hashStr(password)
|
||||
});
|
||||
|
||||
/* ===== password ===== */
|
||||
export const postFindPassword = ({
|
||||
username,
|
||||
code,
|
||||
@@ -63,57 +85,33 @@ export const postFindPassword = ({
|
||||
code: string;
|
||||
password: string;
|
||||
}) =>
|
||||
POST<LoginSuccessResponse>(`/proApi/support/user/account/password/updateByCode`, {
|
||||
POST<LoginSuccessResponseType>(`/proApi/support/user/account/password/updateByCode`, {
|
||||
username,
|
||||
code,
|
||||
password: hashStr(password)
|
||||
});
|
||||
|
||||
export const updatePasswordByOld = ({ oldPsw, newPsw }: { oldPsw: string; newPsw: string }) =>
|
||||
export const updatePasswordByOld = ({ oldPsw, newPsw }: UpdatePasswordByOldBodyType) =>
|
||||
POST('/support/user/account/updatePasswordByOld', {
|
||||
oldPsw: hashStr(oldPsw),
|
||||
newPsw: hashStr(newPsw)
|
||||
});
|
||||
|
||||
export const resetPassword = (newPsw: string) =>
|
||||
POST('/support/user/account/resetExpiredPsw', {
|
||||
newPsw: hashStr(newPsw)
|
||||
});
|
||||
|
||||
/* Check the whether password has expired */
|
||||
// Check the whether password has expired
|
||||
export const getCheckPswExpired = () => GET<boolean>('/support/user/account/checkPswExpired');
|
||||
|
||||
/* ===== notification account ===== */
|
||||
export const updateNotificationAccount = (data: { account: string; verifyCode: string }) =>
|
||||
PUT('/proApi/support/user/team/updateNotificationAccount', data);
|
||||
|
||||
export const updateContact = (data: { contact: string; verifyCode: string }) => {
|
||||
return PUT('/proApi/support/user/account/updateContact', data);
|
||||
};
|
||||
|
||||
export const postLogin = ({ password, ...props }: PostLoginProps) =>
|
||||
POST<LoginSuccessResponse>('/support/user/account/loginByPassword', {
|
||||
...props,
|
||||
password: hashStr(password)
|
||||
});
|
||||
|
||||
export const loginOut = () => GET('/support/user/account/loginout');
|
||||
|
||||
/* ===== user info ===== */
|
||||
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 = (params: WxLoginProps) =>
|
||||
POST<LoginSuccessResponse>(`/proApi/support/user/account/login/wx/getResult`, params);
|
||||
|
||||
export const getCaptchaPic = (username: string) =>
|
||||
GET<{
|
||||
captchaImage: string;
|
||||
}>('/proApi/support/user/account/captcha/getImgCaptcha', { username });
|
||||
|
||||
export const getPreLogin = (username: string) =>
|
||||
GET<preLoginResponse>('/support/user/account/preLogin', { username });
|
||||
|
||||
export const postSyncMembers = () => POST('/proApi/support/user/sync');
|
||||
|
||||
export const GetSearchUserGroupOrg = (
|
||||
|
||||
Reference in New Issue
Block a user