mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
feat: 注册限流配置
feat: 页面加载动画 feat: md样式优化 feat: 移动端全屏覆盖
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { jsonRes } from '@/service/response';
|
||||
import { AuthCode } from '@/service/models/authCode';
|
||||
import { connectToDatabase } from '@/service/mongo';
|
||||
import { connectToDatabase, User } from '@/service/mongo';
|
||||
import { sendCode } from '@/service/utils/sendEmail';
|
||||
import { EmailTypeEnum } from '@/constants/common';
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
const { email, type } = req.query;
|
||||
const { email, type } = req.query as { email: string; type: `${EmailTypeEnum}` };
|
||||
|
||||
if (!email || !type) {
|
||||
throw new Error('缺少参数');
|
||||
@@ -16,6 +16,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
|
||||
await connectToDatabase();
|
||||
|
||||
// 注册人数限流
|
||||
if (type === EmailTypeEnum.register) {
|
||||
const maxCount = process.env.MAX_USER ? +process.env.MAX_USER : Infinity;
|
||||
const userCount = await User.count();
|
||||
|
||||
if (userCount >= maxCount) {
|
||||
throw new Error('当前注册用户已满,请等待名额~');
|
||||
}
|
||||
}
|
||||
|
||||
let code = '';
|
||||
for (let i = 0; i < 6; i++) {
|
||||
code += Math.floor(Math.random() * 10);
|
||||
|
Reference in New Issue
Block a user