Shun Miyazawa 4 years ago
parent
commit
dbd017a233
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/server/models/user.js

+ 5 - 1
src/server/models/user.js

@@ -686,10 +686,14 @@ module.exports = function(crowi) {
   userSchema.statics.updateIsInvitationEmailSended = async function(id) {
   userSchema.statics.updateIsInvitationEmailSended = async function(id) {
     const user = await this.findById(id);
     const user = await this.findById(id);
 
 
-    if (!user) {
+    if (user == null) {
       throw new Error('User not found');
       throw new Error('User not found');
     }
     }
 
 
+    if (user.status !== 5) {
+      throw new Error('The status of the user is not "invited"');
+    }
+
     user.isInvitationEmailSended = true;
     user.isInvitationEmailSended = true;
     user.save();
     user.save();
   };
   };