Shun Miyazawa пре 4 година
родитељ
комит
ccb2f6c102

+ 3 - 1
packages/app/src/server/models/password-reset-order.ts

@@ -6,6 +6,8 @@ import uniqueValidator from 'mongoose-unique-validator';
 import crypto from 'crypto';
 import { getOrCreateModel } from '@growi/core';
 
+import { expiredAt } from '~/server/util/expiredAt';
+
 const ObjectId = mongoose.Schema.Types.ObjectId;
 
 export interface IPasswordResetOrder {
@@ -33,7 +35,7 @@ const schema = new Schema<PasswordResetOrderDocument, PasswordResetOrderModel>({
   email: { type: String, required: true },
   relatedUser: { type: ObjectId, ref: 'User' },
   isRevoked: { type: Boolean, default: false, required: true },
-  expiredAt: { type: Date, default: new Date(Date.now() + 600000), required: true },
+  expiredAt: { type: Date, default: expiredAt, required: true },
 }, {
   timestamps: {
     createdAt: true,

+ 3 - 1
packages/app/src/server/models/user-registration-order.ts

@@ -6,6 +6,8 @@ import uniqueValidator from 'mongoose-unique-validator';
 import crypto from 'crypto';
 import { getOrCreateModel } from '@growi/core';
 
+import { expiredAt } from '~/server/util/expiredAt';
+
 export interface IUserRegistrationOrder {
   token: string,
   email: string,
@@ -28,7 +30,7 @@ const schema = new Schema<UserRegistrationOrderDocument, UserRegistrationOrderMo
   token: { type: String, required: true, unique: true },
   email: { type: String, required: true },
   isRevoked: { type: Boolean, default: false, required: true },
-  expiredAt: { type: Date, default: new Date(Date.now() + 600000), required: true },
+  expiredAt: { type: Date, default: expiredAt, required: true },
 }, {
   timestamps: {
     createdAt: true,

+ 4 - 0
packages/app/src/server/util/expiredAt.ts

@@ -0,0 +1,4 @@
+// 10 minutes
+export const expiredAt = (): Date => {
+  return new Date(Date.now() + 600000);
+};