Skip to content

Commit

Permalink
Try to fix BUG: Database error attempting to change a account.
Browse files Browse the repository at this point in the history
Thanks to bbyszio and xet7 !

Fixes #3855
  • Loading branch information
xet7 committed Jun 11, 2021
1 parent 0fa3a27 commit 7623919
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions models/users.js
Expand Up @@ -952,18 +952,17 @@ if (Meteor.isServer) {
userOrgsArray,
userTeamsArray,
) {
check(fullname, String);
check(username, String);
check(initials, String);
check(password, String);
check(isAdmin, String);
check(isActive, String);
check(email, String);
check(importUsernames, Array);
check(userOrgsArray, Array);
check(userTeamsArray, Array);
if (Meteor.user() && Meteor.user().isAdmin) {
check(fullname, String);
check(username, String);
check(initials, String);
check(password, String);
check(isAdmin, String);
check(isActive, String);
check(email, String);
check(importUsernames, Array);
check(userOrgsArray, Array);
check(userTeamsArray, Array);

const nUsersWithUsername = Users.find({
username,
}).count();
Expand Down Expand Up @@ -1003,9 +1002,9 @@ if (Meteor.isServer) {
}
},
setUsername(username, userId) {
check(username, String);
check(userId, String);
if (Meteor.user() && Meteor.user().isAdmin) {
check(username, String);
check(userId, String);
const nUsersWithUsername = Users.find({
username,
}).count();
Expand All @@ -1021,11 +1020,12 @@ if (Meteor.isServer) {
}
},
setEmail(email, userId) {
check(email, String);
check(username, String);
if (Meteor.user() && Meteor.user().isAdmin) {
if (Array.isArray(email)) {
email = email.shift();
}
check(email, String);
const existingUser = Users.findOne(
{
'emails.address': email,
Expand Down Expand Up @@ -1053,31 +1053,31 @@ if (Meteor.isServer) {
}
},
setUsernameAndEmail(username, email, userId) {
check(username, String);
check(email, String);
check(userId, String);
if (Meteor.user() && Meteor.user().isAdmin) {
check(username, String);
if (Array.isArray(email)) {
email = email.shift();
}
check(email, String);
check(userId, String);
Meteor.call('setUsername', username, userId);
Meteor.call('setEmail', email, userId);
}
},
setPassword(newPassword, userId) {
check(userId, String);
check(newPassword, String);
if (Meteor.user() && Meteor.user().isAdmin) {
check(userId, String);
check(newPassword, String);
if (Meteor.user().isAdmin) {
Accounts.setPassword(userId, newPassword);
}
}
},
setEmailVerified(email, verified, userId) {
check(email, String);
check(verified, Boolean);
check(userId, String);
if (Meteor.user() && Meteor.user().isAdmin) {
check(email, String);
check(verified, Boolean);
check(userId, String);
Users.update(userId, {
$set: {
emails: [
Expand All @@ -1091,9 +1091,9 @@ if (Meteor.isServer) {
}
},
setInitials(initials, userId) {
check(initials, String);
check(userId, String);
if (Meteor.user() && Meteor.user().isAdmin) {
check(initials, String);
check(userId, String);
Users.update(userId, {
$set: {
'profile.initials': initials,
Expand Down

0 comments on commit 7623919

Please sign in to comment.