Skip to content

Commit

Permalink
Merge pull request #305 from RocketChat/change-password
Browse files Browse the repository at this point in the history
Change Password
  • Loading branch information
marceloschmidt committed Jul 15, 2015
2 parents aac0f46 + c1a9783 commit 2444597
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ a.github-fork {
color: inherit;
}
input[type='text'],
input[type='password'],
select {
border-width: 0 0 1px 0;
border-color: @tertiary-font-color;
Expand Down
22 changes: 20 additions & 2 deletions client/views/app/sideNav/userSettingsFlex.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,26 @@ Template.userSettingsFlex.events
'click .cancel-settings': ->
SideNav.closeFlex()

'click .input-submit .save': ->
'click .input-submit .save': (e, instance) ->
selectedLanguage = $('#language').val()
if localStorage.getItem('userLanguage') isnt selectedLanguage
localStorage.setItem 'userLanguage', selectedLanguage
Meteor._reload.reload()
Meteor._reload.reload()

if $('#password').val()
Meteor.call 'setPassword', $('#password').val(), (err, results) ->
if results
toastr.success t('Password_changed_successfully')
if err
toastr.error error.reason


SideNav.closeFlex()
instance.clearForm()

Template.userSettingsFlex.onCreated ->
instance = this

@clearForm = ->
instance.find('#language').value = localStorage.getItem('userLanguage')
instance.find('#password').value = ''
6 changes: 6 additions & 0 deletions client/views/app/sideNav/userSettingsFlex.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ <h4>{{_ "Settings"}}</h4>
</select>
</div>
</div>
<div class="input-line">
<label for="password">{{_ "Password"}}</label>
<div>
<input type="password" name="password" id="password" />
</div>
</div>
<div class="input-submit">
<button class="button primary clean save">{{_ "Save"}}</button>
<button class="button clean cancel-settings">{{_ "Cancel" }}</button>
Expand Down
1 change: 1 addition & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"Oops!" : "Oops",
"others": "others",
"Password" : "Password",
"Password_changed_successfully" : "Password changed successfully",
"Please_wait" : "Please wait",
"Powered_by" : "Powered by",
"Privacy" : "Privacy",
Expand Down
5 changes: 5 additions & 0 deletions server/methods/setPassword.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Meteor.methods
setPassword: (password) ->
if Meteor.userId()
Accounts.setPassword Meteor.userId(), password, { logout: false }
return true

0 comments on commit 2444597

Please sign in to comment.