- Refactor ActiveEntry.sigIn method

- Add own Reset password template
- Check password history and validation in Reset Password
- Add expireTimeInMinute in passwordOptions to control expire time of reset link
- Show sending notification while reset link is sent
This commit is contained in:
Aysel Afsar committed 2016-04-14 15:02:22 -04:00
1 parent 7fa4c33064
commit 1e1c4033a6
8 files changed
+367 -238

No files matched your search

@@ -0,0 +1,42 @@
<template name="resetPassword">
{{#if resetPassword}}
<div id="resetPassword" class="page entryPage" style="{{getOpacityWithCorner}}">
<div class="content-scrollable">
<div class="wrapper-auth">
<div class="entryLogo" style="background-image: url('{{getLogoUrl}}')"></div>
<h1 id="signInPageTitle" class="title-auth">Reset Password</h1>
<p id="signInPageMessage" class="subtitle-auth" style="{{getResetPasswordInMessageColor}}">{{{getResetPasswordMessage}}}</p>
<form>
{{#if resetPasswordErrorMessages}}
<div id="errorMessages" class="list-errors">
{{#each resetPasswordErrorMessages}}
<div class="alert alert-danger list-item">{{this}}</div>
{{/each}}
</div>
{{/if}}
<div class="input-symbol ">
<input id="resetPasswordInput" type="password" name="password" placeholder="Password" style="{{getPasswordStyling}}" />
<span class="fa fa-lock" title="Password"></span>
<!-- <span class="icon-lock" title="Password"></span> -->
</div>
<br>
<br>
<div class="input-symbol">
<input id="resetPasswordConfirmInput" type="password" name="confirm" placeholder="Confirm Password" style="{{getConfirmPasswordStyling}}" />
<span class="fa fa-lock" title="Confirm Password"></span>
<!-- <span class="icon-lock" title="Confirm Password"></span> -->
</div>
<br>
<br>
</form>
<button id="resetPasswordButton" type="submit" class="btn-gray btn-main btn-large" style="{{getButtonColor}}">Reset Password</button><br><br>
</div>
</div>
</div>
{{/if}}
</template>
@@ -0,0 +1,67 @@
Router.route('/resetPassword/:token', {
template: 'resetPassword',
name: 'resetPassword',
onBeforeAction: function() {
var token = this.params.token;
Session.set('_resetPasswordToken', token);
this.next();
}
});
// Reset password template
Template.resetPassword.helpers({
getResetPasswordInMessageColor: function (){
if (ActiveEntry.errorMessages.get('resetPasswordError')) {
return "color: #a94442; background-color: #f2dede; border-color: #ebccd1;"
} else {
return "color: black;"
}
},
getResetPasswordMessage: function (){
if (ActiveEntry.errorMessages.get('resetPasswordError')) {
return ActiveEntry.errorMessages.get('resetPasswordError');
} else {
return Session.get('defaultSignInMessage');
}
},
resetPassword: function(){
return Session.get('_resetPasswordToken');
},
resetPasswordErrorMessages: function() {
if (ActiveEntry.errorMessages.get("password")) {
return [ActiveEntry.errorMessages.get("password")];
}
if (ActiveEntry.errorMessages.get("confirm")) {
return [ActiveEntry.errorMessages.get("confirm")];
}
return;
}
});
Template.resetPassword.events({
'keyup #resetPasswordInput': function (event, template) {
var password = $('#resetPasswordInput').val();
ActiveEntry.verifyPassword(password);
ActiveEntry.errorMessages.set('resetPasswordError', null);
},
'keyup #resetPasswordConfirmInput': function (event, template) {
var password = $('#resetPasswordInput').val();
var confirmPassword = $('#resetPasswordConfirmInput').val();
ActiveEntry.verifyConfirmPassword(password, confirmPassword);
ActiveEntry.errorMessages.set('resetPasswordError', null);
},
'click #resetPasswordButton': function(e, template) {
e.preventDefault();
var password = $('#resetPasswordInput').val();
var passwordConfirm = $('#resetPasswordConfirmInput').val();
if (ActiveEntry.errorMessages.get('password') || ActiveEntry.errorMessages.get('confirm')) {
return;
}
ActiveEntry.resetPassword(password, passwordConfirm);
}
});