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

Allow editing user password

parent 13d0558b
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,9 @@ Meteor.startup ->
{ _id: 'edit-other-user-info',
roles : ['admin']}
{ _id: 'edit-other-user-password',
roles : ['admin']}
{ _id: 'assign-admin-role',
roles : ['admin']}
......
......@@ -23,4 +23,8 @@ Meteor.methods
Meteor.runAsUser userData._id, ->
Meteor.call 'setUsername', userData.username
canEditUserPassword = RocketChat.authz.hasPermission( user._id, 'edit-other-user-password')
if canEditUserPassword and userData.password.trim()
Accounts.setPassword userData._id, userData.password.trim()
return true
......@@ -23,6 +23,7 @@ Template.adminUserEdit.onCreated ->
userData = { _id: Template.currentData()._id }
userData.name = $("#name", ".edit-form").val()
userData.username = $("#username", ".edit-form").val()
userData.password = $("#password", ".edit-form").val()
unless userData._id and userData.name
toastr.error TAPi18n.__('The_field_is_required'), TAPi18n.__('Name')
......@@ -32,4 +33,4 @@ Template.adminUserEdit.onCreated ->
toastr.success t('User_updated_successfully')
instance.cancel()
if error
toastr.error error.reason
\ No newline at end of file
toastr.error error.reason
......@@ -13,6 +13,12 @@
<label for="username">{{_ "Username"}}</label>
<input type="text" id="username" autocomplete="off" value="{{username}}">
</div>
{{#if hasPermission 'edit-other-user-password'}}
<div class="input-line">
<label for="password">{{_ "Password"}}</label>
<input type="password" id="password" autocomplete="off" value="">
</div>
{{/if}}
</form>
</div>
<nav>
......@@ -20,4 +26,4 @@
<button class='button button-block blue save'><span>{{_ "Save"}}</span></button>
</nav>
{{/unless}}
</template>
\ No newline at end of file
</template>
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