Bläddra i källkod

Fix https://github.com/wekan/wekan/issues/1249

soohwa 7 år sedan
förälder
incheckning
deef0855d5
1 ändrade filer med 14 tillägg och 0 borttagningar
  1. 14 0
      models/users.js

+ 14 - 0
models/users.js

@@ -108,6 +108,10 @@ Users.attachSchema(new SimpleSchema({
     type: Boolean,
     optional: true,
   },
+  fromAdmin: {
+    type: Boolean,
+    optional: true,
+  },
 }));
 
 // Search a user in the complete server database by its name or username. This
@@ -435,6 +439,12 @@ if (Meteor.isServer) {
       user.isAdmin = true;
       return user;
     }
+
+    if (options.from == 'admin') {
+      user.fromAdmin = true;
+      return user;
+    }
+
     const disableRegistration = Settings.findOne().disableRegistration;
     if (!disableRegistration) {
       return user;
@@ -524,6 +534,9 @@ if (Meteor.isServer) {
 
   Users.after.insert((userId, doc) => {
 
+    if (doc.fromAdmin)
+        return;
+
     //invite user to corresponding boards
     const disableRegistration = Settings.findOne().disableRegistration;
     if (disableRegistration) {
@@ -582,6 +595,7 @@ if (Meteor.isServer) {
       username: req.body.username,
       email: req.body.email,
       password: 'default',
+      from: 'admin'
     });
 
     JsonRoutes.sendResult(res, {