fix: auth code secret (#6662)

This commit is contained in:
Archer
2026-03-26 22:47:11 +08:00
committed by GitHub
parent 34c85ad5b2
commit 6e6b026d13
2 changed files with 14 additions and 15 deletions
@@ -1,8 +1,9 @@
import type { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
import { MongoUserAuth } from './schema';
import { i18nT } from '../../../../web/i18n/utils';
import { mongoSessionRun } from '../../../common/mongo/sessionRun';
import { UserError } from '@fastgpt/global/common/error/utils';
import { z } from 'zod';
export const addAuthCode = async ({
key,
@@ -33,15 +34,13 @@ export const addAuthCode = async ({
);
};
export const authCode = async ({
key,
type,
code
}: {
key: string;
type: `${UserAuthTypeEnum}`;
code: string;
}) => {
const authCodeSchema = z.object({
key: z.string(),
type: z.enum(UserAuthTypeEnum),
code: z.string()
});
export const authCode = async (props: z.infer<typeof authCodeSchema>) => {
const { key, type, code } = authCodeSchema.parse(props);
return mongoSessionRun(async (session) => {
const result = await MongoUserAuth.findOne(
{
@@ -1,19 +1,19 @@
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
import { NextAPI } from '@/service/middleware/entry';
import type {
ApiKeyHealthParamsType,
ApiKeyHealthResponseType
} from '@fastgpt/global/openapi/support/openapi/api';
import {
ApiKeyHealthParamsSchema
} from '@fastgpt/global/openapi/support/openapi/api';
import { MongoOpenApi } from '@fastgpt/service/support/openapi/schema';
import { useIPFrequencyLimit } from '../../../../../../../packages/service/common/middle/reqFrequencyLimit';
export type invalidBody = {};
async function handler(
req: ApiRequestProps<invalidBody, ApiKeyHealthParamsType>,
req: ApiRequestProps,
res: ApiResponseType<any>
): Promise<ApiKeyHealthResponseType> {
const { apiKey } = req.query;
const { apiKey } = ApiKeyHealthParamsSchema.parse(req.query);
const apiKeyDoc = await MongoOpenApi.findOne({ apiKey }).lean();
if (!apiKeyDoc) {