Merge pull request #5085 from ErisDS/improved-forgotten

Improve the forgotten password flow
This commit is contained in:
Jason Williams 2015-04-03 13:40:16 -05:00
commit 42756b5f44
4 changed files with 29 additions and 5 deletions

View File

@ -11,9 +11,12 @@ var ForgottenController = Ember.Controller.extend(ValidationEngine, {
actions: {
submit: function () {
var self = this,
data = self.getProperties('email');
var data = this.getProperties('email');
this.send('doForgotten', data, true);
},
doForgotten: function (data, delay) {
var self = this;
this.set('email', data.email);
this.toggleProperty('submitting');
this.validate({format: false}).then(function () {
ajax({
@ -26,7 +29,7 @@ var ForgottenController = Ember.Controller.extend(ValidationEngine, {
}
}).then(function () {
self.toggleProperty('submitting');
self.notifications.showSuccess('Please check your email for instructions.', {delayed: true});
self.notifications.showSuccess('Please check your email for instructions.', {delayed: delay});
self.set('email', '');
self.transitionToRoute('signin');
}).catch(function (resp) {

View File

@ -3,6 +3,7 @@ import ValidationEngine from 'ghost/mixins/validation-engine';
var SigninController = Ember.Controller.extend(SimpleAuth.AuthenticationControllerMixin, ValidationEngine, {
authenticator: 'simple-auth-authenticator:oauth2-password-grant',
forgotten: Ember.inject.controller(),
validationType: 'signin',
@ -31,6 +32,14 @@ var SigninController = Ember.Controller.extend(SimpleAuth.AuthenticationControll
}).catch(function (errors) {
self.notifications.showErrors(errors);
});
},
forgotten: function () {
if (this.get('model.identification')) {
return this.get('forgotten').send('doForgotten', {email: this.get('model.identification')}, false);
}
this.transitionToRoute('forgotten');
}
}
});

View File

@ -140,6 +140,18 @@
color: $midgrey;
}
.forgotten-link {
display: inline-block;
height: auto;
width: auto;
margin: 0;
padding: 0;
font-size: 1.25rem;
color: darken($midgrey, 10%);
text-transform: none;
letter-spacing: 0;
}
a {
color: darken($midgrey, 10%);
font-size: 0.9em;

View File

@ -12,7 +12,7 @@
</div>
<button class="btn btn-blue" type="submit" {{action "validateAndAuthenticate"}} {{bind-attr disabled=submitting}}>Log in</button>
<section class="meta">
{{#link-to 'forgotten' class="forgotten-password"}}Forgotten password?{{/link-to}}
<button {{action 'forgotten'}} class="forgotten-link btn btn-link">Forgotten password?</button>
</section>
</form>
</section>