Shun Miyazawa 4 лет назад
Родитель
Сommit
3155396e89
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      src/server/models/user.js

+ 12 - 0
src/server/models/user.js

@@ -63,6 +63,7 @@ module.exports = function(crowi) {
     createdAt: { type: Date, default: Date.now },
     lastLoginAt: { type: Date },
     admin: { type: Boolean, default: 0, index: true },
+    invitationEmailSended: { type: Date, default: null },
   }, {
     toObject: {
       transform: (doc, ret, opt) => {
@@ -682,6 +683,17 @@ module.exports = function(crowi) {
     return username;
   };
 
+  userSchema.statics.updateInvitationEmailSended = async function(id) {
+    const user = await this.findById(id);
+
+    if (!user) {
+      throw new Error('User not found');
+    }
+
+    user.invitationEmailSended = new Date();
+    user.save();
+  };
+
   class UserUpperLimitException {
 
     constructor() {