From a7f1173f932bfc0f388de654e9d1122566aeee8c Mon Sep 17 00:00:00 2001 From: David Arvelo Date: Mon, 30 Jun 2014 16:07:30 -0400 Subject: [PATCH] Signin Validation closes #3120 - create `validateAndAuthenticate` action to validate, send `authenticate` action on success, notifications on error - signin template uses `validateAndAuthenticate` action instead of `authenticate` action --- core/client/controllers/signin.js | 18 +++++++++++++++++- core/client/templates/signin.hbs | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/core/client/controllers/signin.js b/core/client/controllers/signin.js index 623f3933ef..de4fe8debf 100644 --- a/core/client/controllers/signin.js +++ b/core/client/controllers/signin.js @@ -1,5 +1,21 @@ -var SigninController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, { +import ValidationEngine from 'ghost/mixins/validation-engine'; + +var SigninController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, ValidationEngine, { authenticatorFactory: 'ember-simple-auth-authenticator:oauth2-password-grant', + + validationType: 'signin', + + actions: { + validateAndAuthenticate: function () { + var self = this; + + this.validate({ format: false }).then(function () { + self.send('authenticate'); + }).catch(function (errors) { + self.notifications.showErrors(errors); + }); + } + } }); export default SigninController; diff --git a/core/client/templates/signin.hbs b/core/client/templates/signin.hbs index b8bb3ccddd..caa4f6552f 100644 --- a/core/client/templates/signin.hbs +++ b/core/client/templates/signin.hbs @@ -1,12 +1,12 @@
-