mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 13:53:50 +00:00
@@ -3,8 +3,6 @@ LOG_DEPTH=3
|
||||
DEFAULT_ROOT_PSW=123456
|
||||
# 数据库最大连接数
|
||||
DB_MAX_LINK=5
|
||||
# token
|
||||
TOKEN_KEY=dfdasfdas
|
||||
# 文件阅读时的密钥
|
||||
FILE_TOKEN_KEY=filetokenkey
|
||||
# root key, 最高权限
|
||||
@@ -65,6 +63,8 @@ CHECK_INTERNAL_IP=false
|
||||
PASSWORD_LOGIN_LOCK_SECONDS=
|
||||
# 密码过期月份,不设置则不会过期
|
||||
PASSWORD_EXPIRED_MONTH=
|
||||
# 最大登录客户端数量,默认为 10
|
||||
MAX_LOGIN_SESSION=
|
||||
|
||||
# 特殊配置
|
||||
# 自定义跨域,不配置时,默认都允许跨域(逗号分割)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { MongoUser } from '@fastgpt/service/support/user/schema';
|
||||
import { createJWT, setCookie } from '@fastgpt/service/support/permission/controller';
|
||||
import { setCookie } from '@fastgpt/service/support/permission/controller';
|
||||
import { getUserDetail } from '@fastgpt/service/support/user/controller';
|
||||
import type { PostLoginProps } from '@fastgpt/global/support/user/api.d';
|
||||
import { UserStatusEnum } from '@fastgpt/global/support/user/constant';
|
||||
@@ -13,6 +13,8 @@ import { addOperationLog } from '@fastgpt/service/support/operationLog/addOperat
|
||||
import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants';
|
||||
import { UserAuthTypeEnum } from '@fastgpt/global/support/user/auth/constants';
|
||||
import { authCode } from '@fastgpt/service/support/user/auth/controller';
|
||||
import { createUserSession } from '@fastgpt/service/support/user/session';
|
||||
import requestIp from 'request-ip';
|
||||
|
||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const { username, password, code } = req.body as PostLoginProps;
|
||||
@@ -61,20 +63,22 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
lastLoginTmbId: userDetail.team.tmbId
|
||||
});
|
||||
|
||||
const token = await createUserSession({
|
||||
userId: user._id,
|
||||
teamId: userDetail.team.teamId,
|
||||
tmbId: userDetail.team.tmbId,
|
||||
isRoot: username === 'root',
|
||||
ip: requestIp.getClientIp(req)
|
||||
});
|
||||
|
||||
setCookie(res, token);
|
||||
|
||||
pushTrack.login({
|
||||
type: 'password',
|
||||
uid: user._id,
|
||||
teamId: userDetail.team.teamId,
|
||||
tmbId: userDetail.team.tmbId
|
||||
});
|
||||
|
||||
const token = createJWT({
|
||||
...userDetail,
|
||||
isRoot: username === 'root'
|
||||
});
|
||||
|
||||
setCookie(res, token);
|
||||
|
||||
addOperationLog({
|
||||
tmbId: userDetail.team.tmbId,
|
||||
teamId: userDetail.team.teamId,
|
||||
|
Reference in New Issue
Block a user