mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
[web] Set ProjectInvite privileges type to Union GitOrigin-RevId: a68e732bec5f6a7752b1110075736cb33454e6eb
42 lines
960 B
JavaScript
42 lines
960 B
JavaScript
import mongoose from '../infrastructure/Mongoose.mjs'
|
|
|
|
const { Schema } = mongoose
|
|
const { ObjectId } = Schema
|
|
|
|
export const EXPIRY_IN_SECONDS = 60 * 60 * 24 * 30
|
|
|
|
const ExpiryDate = function () {
|
|
const timestamp = new Date()
|
|
timestamp.setSeconds(timestamp.getSeconds() + EXPIRY_IN_SECONDS)
|
|
return timestamp
|
|
}
|
|
|
|
export const ProjectInviteSchema = new Schema(
|
|
{
|
|
email: String,
|
|
tokenHmac: String,
|
|
sendingUserId: ObjectId,
|
|
projectId: ObjectId,
|
|
// privileges contains a PrivilegeLevels value, which may be Boolean `false` or a String
|
|
privileges: {
|
|
type: Schema.Types.Union,
|
|
of: [String, Boolean],
|
|
},
|
|
createdAt: { type: Date, default: Date.now },
|
|
expires: {
|
|
type: Date,
|
|
default: ExpiryDate,
|
|
index: { expireAfterSeconds: 10 },
|
|
},
|
|
},
|
|
{
|
|
collection: 'projectInvites',
|
|
minimize: false,
|
|
}
|
|
)
|
|
|
|
export const ProjectInvite = mongoose.model(
|
|
'ProjectInvite',
|
|
ProjectInviteSchema
|
|
)
|