瀏覽代碼

remove invitation code

guillaume 7 年之前
父節點
當前提交
e2ae5d6b8e
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      models/users.js

+ 6 - 5
models/users.js

@@ -501,12 +501,13 @@ if (Meteor.isServer) {
     } else {
       user.profile = {icode: options.profile.invitationcode};
       user.profile.boardView = 'board-view-lists';
-    }
-
-    // Deletes the invitation.
-    InvitationCodes.remove(invitationCode._id);
 
-    return user;
+      // Deletes the invitation code after the user was created successfully.
+      setTimeout(Meteor.bindEnvironment(() => {
+        InvitationCodes.remove({'_id': invitationCode._id});
+      }), 200);
+      return user;
+    }
   });
 }