From deef0855d5420c7fa30c138d68cdae8b8f5c690d Mon Sep 17 00:00:00 2001 From: soohwa Date: Mon, 25 Sep 2017 21:03:18 +0900 Subject: Fix https://github.com/wekan/wekan/issues/1249 --- models/users.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index c2238cde..43faf4d4 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: 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, { -- cgit v1.2.3-1-g7c22 From ee94735922a7b992df82fce5efc1eb732fc994d3 Mon Sep 17 00:00:00 2001 From: soohwa Date: Mon, 25 Sep 2017 22:14:13 +0900 Subject: Lint error --- models/users.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 43faf4d4..8d154c4b 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, { -- cgit v1.2.3-1-g7c22 From 42ca385a36ace9e4553526a40c6635e0b58a7c3c Mon Sep 17 00:00:00 2001 From: soohwa Date: Sun, 1 Oct 2017 10:15:54 +0900 Subject: Fix password not saved --- models/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 8d154c4b..8f8e446a 100644 --- a/models/users.js +++ b/models/users.js @@ -594,7 +594,7 @@ if (Meteor.isServer) { const id = Accounts.createUser({ username: req.body.username, email: req.body.email, - password: 'default', + password: req.body.password, from: 'admin', }); -- cgit v1.2.3-1-g7c22 From 273784b9e46a83e02d65cd0281c93d5d0b3bb6cc Mon Sep 17 00:00:00 2001 From: soohwa Date: Fri, 6 Oct 2017 01:21:45 +0900 Subject: Clear "fromAdmin". Thx to nztqa. --- models/users.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 8f8e446a..adef3ad5 100644 --- a/models/users.js +++ b/models/users.js @@ -534,8 +534,10 @@ if (Meteor.isServer) { Users.after.insert((userId, doc) => { - if (doc.fromAdmin) + if (doc.fromAdmin) { + Users.update(doc._id, { $set: { fromAdmin: '' } }); return; + } //invite user to corresponding boards const disableRegistration = Settings.findOne().disableRegistration; -- cgit v1.2.3-1-g7c22 From 8daa5b4848cd929d298ca2dfb2170a6b8dab60df Mon Sep 17 00:00:00 2001 From: soohwa Date: Fri, 6 Oct 2017 23:08:22 +0900 Subject: Change fromAdmin into createdThroughApi --- models/users.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index adef3ad5..459462e3 100644 --- a/models/users.js +++ b/models/users.js @@ -108,7 +108,7 @@ Users.attachSchema(new SimpleSchema({ type: Boolean, optional: true, }, - fromAdmin: { + createdThroughApi: { type: Boolean, optional: true, }, @@ -441,7 +441,7 @@ if (Meteor.isServer) { } if (options.from === 'admin') { - user.fromAdmin = true; + user.createdThroughApi = true; return user; } @@ -534,8 +534,8 @@ if (Meteor.isServer) { Users.after.insert((userId, doc) => { - if (doc.fromAdmin) { - Users.update(doc._id, { $set: { fromAdmin: '' } }); + if (doc.createdThroughApi) { + Users.update(doc._id, { $set: { createdThroughApi: '' } }); return; } -- cgit v1.2.3-1-g7c22 From b9be17360f5fc7799cc720d40e2e52ee07d3cd38 Mon Sep 17 00:00:00 2001 From: soohwa Date: Sat, 7 Oct 2017 08:33:28 +0900 Subject: Add comment --- models/users.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 459462e3..6b835d41 100644 --- a/models/users.js +++ b/models/users.js @@ -535,6 +535,12 @@ if (Meteor.isServer) { Users.after.insert((userId, doc) => { if (doc.createdThroughApi) { + // The admin user should be able to create a user despite disabling registration because + // it is two different things (registration and creation). + // So, when a new user is created via the api (only admin user can do that) one must avoid + // the disableRegistration check. + // Issue : https://github.com/wekan/wekan/issues/1232 + // PR : https://github.com/wekan/wekan/pull/1251 Users.update(doc._id, { $set: { createdThroughApi: '' } }); return; } -- cgit v1.2.3-1-g7c22 From ad607c1291c38df26e51c03113a49ca8112b32ec Mon Sep 17 00:00:00 2001 From: soohwa Date: Sun, 8 Oct 2017 18:15:11 +0900 Subject: Remove trailing space --- models/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'models/users.js') diff --git a/models/users.js b/models/users.js index 6b835d41..3d4ff935 100644 --- a/models/users.js +++ b/models/users.js @@ -537,7 +537,7 @@ if (Meteor.isServer) { if (doc.createdThroughApi) { // The admin user should be able to create a user despite disabling registration because // it is two different things (registration and creation). - // So, when a new user is created via the api (only admin user can do that) one must avoid + // So, when a new user is created via the api (only admin user can do that) one must avoid // the disableRegistration check. // Issue : https://github.com/wekan/wekan/issues/1232 // PR : https://github.com/wekan/wekan/pull/1251 -- cgit v1.2.3-1-g7c22