- Improves layout of new password requestedpull/2427/head
parent
7767b808ff
commit
0f60d14d1c
@ -1,19 +0,0 @@ |
||||
<template name="requestPasswordChange"> |
||||
<div class="content"> |
||||
<div class="attention-message"> |
||||
<i class="icon-attention"></i> |
||||
<span>{{_ 'You_need_to_change_your_password'}}</span> |
||||
</div> |
||||
<div class="rocket-form request-password"> |
||||
<form> |
||||
<fieldset> |
||||
<label for="oldPassword">{{_ "Old_Password"}}</label><input type="password" name="oldPassword" id="oldPassword" /> |
||||
<label for="newPassword">{{_ "Password"}}</label><input type="password" name="newPassword" id="newPassword" /> |
||||
<div class="submit"> |
||||
<button type="submit" class="button save"><i class="icon-send"></i><span>{{_ "Save"}}</span></button> |
||||
</div> |
||||
</fieldset> |
||||
</form> |
||||
</div> |
||||
</div> |
||||
</template> |
||||
@ -1,33 +0,0 @@ |
||||
Template.requestPasswordChange.events({ |
||||
'submit'(e, instance) { |
||||
e.preventDefault(); |
||||
oldPassword = s.trim(instance.$('#oldPassword').val()); |
||||
newPassword = s.trim(instance.$('#newPassword').val()); |
||||
instance.changePassword(oldPassword, newPassword); |
||||
} |
||||
}) |
||||
|
||||
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) { |
||||
toastr.error(t('Incorrect_Password')); |
||||
} else { |
||||
Meteor.call('clearRequirePasswordChange', function() { |
||||
toastr.success(t('Password_changed_successfully')) |
||||
return true; |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
}) |
||||
|
||||
Template.requestPasswordChange.onRendered(function() { |
||||
this.$('#oldPassword').focus(); |
||||
}) |
||||
@ -0,0 +1,12 @@ |
||||
Meteor.methods |
||||
setUserPassword: (password) -> |
||||
if not Meteor.userId() |
||||
throw new Meteor.Error 'invalid-user', '[methods] setUserPassword -> Invalid user' |
||||
|
||||
user = RocketChat.models.Users.findOneById Meteor.userId() |
||||
if user and user.requirePasswordChange isnt true |
||||
throw new Meteor.Error 'not-authorized', '[methods] setUserPassword -> Not authorized' |
||||
|
||||
Accounts.setPassword(Meteor.userId(), password, { logout: false }); |
||||
|
||||
return true; |
||||
Loading…
Reference in new issue