From 57d6180a7a432f2429e6deab1da1926ec692fd8e Mon Sep 17 00:00:00 2001 From: none Date: Sat, 23 Sep 2017 15:20:11 +0900 Subject: [PATCH 1/3] Allow admin to create user despite disabling registration throught rest api. --- models/users.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/models/users.js b/models/users.js index c2238cde0..9744d51cb 100644 --- a/models/users.js +++ b/models/users.js @@ -108,6 +108,10 @@ Users.attachSchema(new SimpleSchema({ type: Boolean, optional: true, }, + fromAdmin: { + type: Boolean, + optional: false, + }, })); // 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, { From f7a1c4896bc9d80a864c71a272827dc6d2cbddaa Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sun, 24 Sep 2017 17:08:28 +0300 Subject: [PATCH 2/3] Fix lint errors. --- models/users.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/users.js b/models/users.js index 9744d51cb..505ed93e1 100644 --- a/models/users.js +++ b/models/users.js @@ -440,7 +440,7 @@ if (Meteor.isServer) { return user; } - if (options.from == 'admin') { + if (options.from === 'admin') { user.fromAdmin = true; return user; } @@ -535,7 +535,7 @@ if (Meteor.isServer) { Users.after.insert((userId, doc) => { if (doc.fromAdmin) - return; + return; //invite user to corresponding boards const disableRegistration = Settings.findOne().disableRegistration; @@ -595,7 +595,7 @@ if (Meteor.isServer) { username: req.body.username, email: req.body.email, password: 'default', - from: 'admin' + from: 'admin', }); JsonRoutes.sendResult(res, { From d4d20d2a43a8062f419a33f4ba85977d8c1dd3a0 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 25 Sep 2017 00:49:07 +0300 Subject: [PATCH 3/3] REST API: Create user despite disabling registration. Thanks to soohwa ! Closes #1232 --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27470c6e1..8e02ecbcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,14 +4,15 @@ This release adds the following new features: * [Add translations (en/de/fi) for email notifications regarding checklists and checklist items](https://github.com/wekan/wekan/pull/1238); -* [Added plus button to add card on top of the list](https://github.com/wekan/wekan/pull/1244). +* [Added plus button to add card on top of the list](https://github.com/wekan/wekan/pull/1244); +* [REST API: Create user despite disabling registration](https://github.com/wekan/wekan/issues/1232). and fixes the following bugs: * [Checklist items are lost when moving items to another checklist](https://github.com/wekan/wekan/pull/1240); * [Keep state of checklist items when moved to another checklist](https://github.com/wekan/wekan/pull/1242). -Thanks to GitHub users GhassenRjab, mario-orlicky, umbertooo and xet7 for their contributions. +Thanks to GitHub users GhassenRjab, mario-orlicky, soohwa, umbertooo and xet7 for their contributions. # v0.39 2017-09-18 Wekan release