Explorar o código

remove invitation code

guillaume %!s(int64=7) %!d(string=hai) anos
pai
achega
e2ae5d6b8e
Modificáronse 1 ficheiros con 6 adicións e 5 borrados
  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;
+    }
   });
 }