mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-12 04:15:39 +08:00
Implement authentication, waitlist, and logging upgrades
This commit is contained in:
26
server/models/InvitationCode.ts
Normal file
26
server/models/InvitationCode.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import mongoose from 'mongoose'
|
||||
|
||||
const { Schema } = mongoose
|
||||
|
||||
export interface InvitationCodeDocument extends mongoose.Document {
|
||||
code: string
|
||||
createdBy: mongoose.Types.ObjectId
|
||||
createdAt: Date
|
||||
expiresAt?: Date
|
||||
usedBy?: mongoose.Types.ObjectId
|
||||
usedAt?: Date
|
||||
}
|
||||
|
||||
const invitationSchema = new mongoose.Schema<InvitationCodeDocument>({
|
||||
code: { type: String, required: true, unique: true, uppercase: true, trim: true },
|
||||
createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||
createdAt: { type: Date, default: () => new Date() },
|
||||
expiresAt: { type: Date },
|
||||
usedBy: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||
usedAt: { type: Date },
|
||||
})
|
||||
|
||||
export const InvitationCode =
|
||||
(mongoose.models.InvitationCode as mongoose.Model<InvitationCodeDocument> | undefined) ||
|
||||
mongoose.model<InvitationCodeDocument>('InvitationCode', invitationSchema)
|
||||
|
||||
Reference in New Issue
Block a user