summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
authorThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-08 11:34:05 +0700
committerThuan Pham Quoc <thuanpq.io@gmail.com>2017-11-08 11:34:05 +0700
commite3b7f85cc35b650e72259909608237ea0347a7fb (patch)
tree83d342f7a56891f2ffa4c4f92172df6c5f5df8b8 /models/users.js
parent3bead1bf78758e81a97150053c5df8e6be2d6fe1 (diff)
downloadwekan-e3b7f85cc35b650e72259909608237ea0347a7fb.tar.gz
wekan-e3b7f85cc35b650e72259909608237ea0347a7fb.tar.bz2
wekan-e3b7f85cc35b650e72259909608237ea0347a7fb.zip
Updated users methods to get user id from client on updating user data, is aimed to support admin update other user profile
Diffstat (limited to 'models/users.js')
-rw-r--r--models/users.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/models/users.js b/models/users.js
index abc0f82d..a4106023 100644
--- a/models/users.js
+++ b/models/users.js
@@ -325,13 +325,13 @@ Users.mutations({
});
Meteor.methods({
- setUsername(username) {
+ setUsername(username, userId) {
check(username, String);
const nUsersWithUsername = Users.find({ username }).count();
if (nUsersWithUsername > 0) {
throw new Meteor.Error('username-already-taken');
} else {
- Users.update(this.userId, { $set: { username } });
+ Users.update(userId, {$set: {username}});
}
},
toggleSystemMessages() {
@@ -342,13 +342,13 @@ Meteor.methods({
check(limit, Number);
Meteor.user().setShowCardsCountAt(limit);
},
- setEmail(email) {
+ setEmail(email, userId) {
check(email, String);
const existingUser = Users.findOne({ 'emails.address': email }, { fields: { _id: 1 } });
if (existingUser) {
throw new Meteor.Error('email-already-taken');
} else {
- Users.update(this.userId, {
+ Users.update(userId, {
$set: {
emails: [{
address: email,
@@ -358,11 +358,12 @@ Meteor.methods({
});
}
},
- setUsernameAndEmail(username, email) {
+ setUsernameAndEmail(username, email, userId) {
check(username, String);
check(email, String);
- Meteor.call('setUsername', username);
- Meteor.call('setEmail', email);
+ check(userId, String);
+ Meteor.call('setUsername', username, userId);
+ Meteor.call('setEmail', email, userId);
},
});