mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 09:16:26 +08:00
Finalize admin tools and transmission fault flow
This commit is contained in:
@@ -2,6 +2,8 @@ import mongoose from 'mongoose'
|
||||
|
||||
const { Schema } = mongoose
|
||||
|
||||
export type InvitationChannel = 'user' | 'bootstrap' | 'manual' | 'admin'
|
||||
|
||||
export interface InvitationCodeDocument extends mongoose.Document {
|
||||
code: string
|
||||
createdBy?: mongoose.Types.ObjectId
|
||||
@@ -9,7 +11,7 @@ export interface InvitationCodeDocument extends mongoose.Document {
|
||||
expiresAt?: Date
|
||||
usedBy?: mongoose.Types.ObjectId
|
||||
usedAt?: Date
|
||||
channel: 'user' | 'bootstrap' | 'manual'
|
||||
channel: InvitationChannel
|
||||
label?: string
|
||||
}
|
||||
|
||||
@@ -20,7 +22,7 @@ const invitationSchema = new mongoose.Schema<InvitationCodeDocument>({
|
||||
expiresAt: { type: Date },
|
||||
usedBy: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
usedAt: { type: Date },
|
||||
channel: { type: String, enum: ['user', 'bootstrap', 'manual'], default: 'user' },
|
||||
channel: { type: String, enum: ['user', 'bootstrap', 'manual', 'admin'], default: 'user' },
|
||||
label: { type: String, trim: true },
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import mongoose from 'mongoose'
|
||||
|
||||
export type UserRole = 'user' | 'admin' | 'dev'
|
||||
|
||||
export interface UserDocument extends mongoose.Document {
|
||||
email: string
|
||||
passwordHash: string
|
||||
name?: string
|
||||
role: 'user' | 'admin'
|
||||
role: UserRole
|
||||
createdAt: Date
|
||||
lastLoginAt?: Date
|
||||
tokenVersion: number
|
||||
@@ -17,7 +19,7 @@ const userSchema = new mongoose.Schema<UserDocument>({
|
||||
email: { type: String, required: true, unique: true, lowercase: true, trim: true },
|
||||
passwordHash: { type: String, required: true },
|
||||
name: { type: String, trim: true },
|
||||
role: { type: String, enum: ['user', 'admin'], default: 'user' },
|
||||
role: { type: String, enum: ['user', 'admin', 'dev'], default: 'user' },
|
||||
createdAt: { type: Date, default: () => new Date() },
|
||||
lastLoginAt: { type: Date },
|
||||
tokenVersion: { type: Number, default: 0 },
|
||||
|
||||
Reference in New Issue
Block a user