From 60937e8cccae667518ab47b41bb2f8bd1f91b74d Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 30 Mar 2015 19:52:48 +0200 Subject: [PATCH] Improve the forgotten password flow - if the user has filled out their email already when they hit 'forgotten password' then automatically fill out and submit the form - this will look better when we have spinners on the buttons --- ghost/admin/app/controllers/forgotten.js | 11 +++++++---- ghost/admin/app/controllers/signin.js | 9 +++++++++ ghost/admin/app/styles/layouts/auth.scss | 12 ++++++++++++ ghost/admin/app/templates/signin.hbs | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ghost/admin/app/controllers/forgotten.js b/ghost/admin/app/controllers/forgotten.js index ed1bc2ac28..f78f165637 100644 --- a/ghost/admin/app/controllers/forgotten.js +++ b/ghost/admin/app/controllers/forgotten.js @@ -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) { diff --git a/ghost/admin/app/controllers/signin.js b/ghost/admin/app/controllers/signin.js index 36462c8d16..0cf94b49b2 100644 --- a/ghost/admin/app/controllers/signin.js +++ b/ghost/admin/app/controllers/signin.js @@ -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'); } } }); diff --git a/ghost/admin/app/styles/layouts/auth.scss b/ghost/admin/app/styles/layouts/auth.scss index fe9c79b823..fec2f99918 100644 --- a/ghost/admin/app/styles/layouts/auth.scss +++ b/ghost/admin/app/styles/layouts/auth.scss @@ -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; diff --git a/ghost/admin/app/templates/signin.hbs b/ghost/admin/app/templates/signin.hbs index 6b505101c1..3ca687094e 100644 --- a/ghost/admin/app/templates/signin.hbs +++ b/ghost/admin/app/templates/signin.hbs @@ -12,7 +12,7 @@
- {{#link-to 'forgotten' class="forgotten-password"}}Forgotten password?{{/link-to}} +