Skip to content
Snippets Groups Projects
Commit 6f49e8c4 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Select user after inserting; old and new password must differ

parent 5443507d
No related branches found
Tags 6.3.0-rc.10
No related merge requests found
......@@ -353,6 +353,7 @@
"Notify_all_in_this_room" : "Notify all in this room",
"OAuth_Application" : "OAuth Application",
"OAuth_Applications" : "OAuth Applications",
"Old_and_new_password_must_be_different" : "The new password must be different from the old password.",
"Old_and_new_password_required" : "You need to provide both old and new password for changing your password.",
"Old_Password" : "Old Password",
"Online" : "Online",
......@@ -552,6 +553,7 @@
"User__username__was_removed_as_a_moderator_by__user_by_" : "User <em>__username__</em> was removed as a moderator by <em>__user_by__</em>",
"User__username__was_removed_as_a_owner_by__user_by_" : "User <em>__username__</em> was removed as a owner by <em>__user_by__</em>",
"User_added_by" : "User <em>__user_added__</em> added by <em>__user_by__</em>.",
"User_added_successfully" : "User added successfully",
"User_Channels" : "User Channels",
"User_has_been_activated" : "User has been activated",
"User_has_been_deactivated" : "User has been deactivated",
......
......@@ -25,10 +25,10 @@ Meteor.methods
if not userData._id
if not RocketChat.checkUsernameAvailability userData.username
throw new Meteor.Error 'username-unavailable', "#{username} is already in use :("
throw new Meteor.Error 'username-unavailable', "#{userData.username} is already in use :("
if userData.email and not RocketChat.checkEmailAvailability userData.email
throw new Meteor.Error 'username-unavailable', "#{username} is already in use :("
throw new Meteor.Error 'email-unavailable', "#{userData.email} is already in use :("
# insert user
createUser = { username: userData.username, password: userData.password }
......@@ -39,6 +39,7 @@ Meteor.methods
if userData.requirePasswordChange
Meteor.users.update { _id: _id }, { $set: { name: userData.name, requirePasswordChange: userData.requirePasswordChange } }
return _id
else
#update user
Meteor.users.update { _id: userData._id }, { $set: { name: userData.name, requirePasswordChange: userData.requirePasswordChange } }
......@@ -50,4 +51,4 @@ Meteor.methods
if canEditUserPassword and userData.password.trim()
Accounts.setPassword userData._id, userData.password.trim()
return true
return true
......@@ -47,9 +47,17 @@ Template.adminUserEdit.onCreated ->
@save = =>
if this.validate()
Meteor.call 'insertOrUpdateUser', this.getUserData(), (error, result) =>
userData = this.getUserData()
Meteor.call 'insertOrUpdateUser', userData, (error, result) =>
if result
toastr.success t('User_updated_successfully')
if userData._id
toastr.success t('User_updated_successfully')
else
toastr.success t('User_added_successfully')
Session.set('adminSelectedUser', result);
Session.set('showUserInfo', result);
Meteor.subscribe 'fullUserData', userData.username, 1
this.cancel()
if error
toastr.error error.reason
......@@ -11,6 +11,8 @@ Template.requestPasswordChange.onCreated(function() {
this.changePassword = function(oldPassword, newPassword) {
if (!oldPassword || !newPassword) {
toastr.warning(t('Old_and_new_password_required'));
} else if (oldPassword === newPassword) {
toastr.warning(t('Old_and_new_password_must_be_different'));
} else {
Accounts.changePassword(oldPassword, newPassword, function(error) {
if(error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment