mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* Psw (#4748) * feat: 添加重置密码功能及相关接口 - 在用户模型中新增 passwordUpdateTime 字段以记录密码更新时间。 - 更新用户模式以支持密码更新时间的存储。 - 新增重置密码的模态框组件,允许用户重置密码。 - 实现重置密码的 API 接口,支持根据用户 ID 更新密码。 - 更新相关国际化文件,添加重置密码的提示信息。 * 更新国际化文件,添加重置密码相关提示信息,并优化重置密码模态框的实现。修复部分代码逻辑,确保用户体验流畅。 * 更新国际化文件,添加重置密码相关提示信息,优化重置密码模态框的实现,修复部分代码逻辑,确保用户体验流畅。新增获取用户密码更新时间的API接口,并调整相关逻辑以支持密码重置功能。 * update * fix * fix * Added environment variables NEXT_PUBLIC_PASSWORD_UPDATETIME to support password update time configuration, update related logic to implement password mandatory update function, and optimize the implementation of reset password modal box to improve user experience. * update index * 更新用户密码重置功能,调整相关API接口,优化重置密码模态框的实现,确保用户体验流畅。修复部分代码逻辑,更新国际化提示信息。 * 删除获取用户密码更新时间的API接口,并在布局组件中移除不必要的重置密码模态框。优化代码结构,提升可维护性。 * update * perf: reset expired password code * perf: layout child components * doc * remove invalid env * perf: update password code --------- Co-authored-by: dreamer6680 <1468683855@qq.com>
75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import { connectionMongo, getMongoModel } from '../../common/mongo';
|
|
const { Schema } = connectionMongo;
|
|
import { hashStr } from '@fastgpt/global/common/string/tools';
|
|
import type { UserModelSchema } from '@fastgpt/global/support/user/type';
|
|
import { UserStatusEnum, userStatusMap } from '@fastgpt/global/support/user/constant';
|
|
import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/constant';
|
|
|
|
export const userCollectionName = 'users';
|
|
|
|
const UserSchema = new Schema({
|
|
status: {
|
|
type: String,
|
|
enum: Object.keys(userStatusMap),
|
|
default: UserStatusEnum.active
|
|
},
|
|
username: {
|
|
// 可以是手机/邮箱,新的验证都只用手机
|
|
type: String,
|
|
required: true,
|
|
unique: true // 唯一
|
|
},
|
|
phonePrefix: Number,
|
|
password: {
|
|
type: String,
|
|
required: true,
|
|
set: (val: string) => hashStr(val),
|
|
get: (val: string) => hashStr(val),
|
|
select: false
|
|
},
|
|
passwordUpdateTime: Date,
|
|
createTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
promotionRate: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
openaiAccount: {
|
|
type: {
|
|
key: String,
|
|
baseUrl: String
|
|
}
|
|
},
|
|
timezone: {
|
|
type: String,
|
|
default: 'Asia/Shanghai'
|
|
},
|
|
lastLoginTmbId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamMemberCollectionName
|
|
},
|
|
|
|
inviterId: {
|
|
// 谁邀请注册的
|
|
type: Schema.Types.ObjectId,
|
|
ref: userCollectionName
|
|
},
|
|
fastgpt_sem: Object,
|
|
sourceDomain: String,
|
|
contact: String,
|
|
|
|
/** @deprecated */
|
|
avatar: String
|
|
});
|
|
|
|
try {
|
|
// Admin charts
|
|
UserSchema.index({ createTime: -1 });
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoUser = getMongoModel<UserModelSchema>(userCollectionName, UserSchema);
|