Explorar o código

create new schema

Shun Miyazawa %!s(int64=4) %!d(string=hai) anos
pai
achega
3155396e89
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  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() {