Merge pull request #3159 from darvelo/signin-validation

Signin Validation
This commit is contained in:
Hannah Wolfe 2014-07-01 17:39:57 +01:00
commit c5771e73bb
2 changed files with 19 additions and 3 deletions

View File

@ -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;

View File

@ -1,12 +1,12 @@
<section class="login-box js-login-box fade-in">
<form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'authenticate' on='submit'}}>
<form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'validateAndAuthenticate' on='submit'}}>
<div class="email-wrap">
{{input class="email" type="email" placeholder="Email Address" name="identification" autofocus="autofocus" autocapitalize="off" autocorrect="off" value=identification}}
</div>
<div class="password-wrap">
{{input class="password" type="password" placeholder="Password" name="password" value=password}}
</div>
<button class="button-save" type="submit" {{action "authenticate"}} {{bind-attr disabled=submitting}}>Log in</button>
<button class="button-save" type="submit" {{action "validateAndAuthenticate"}} {{bind-attr disabled=submitting}}>Log in</button>
<section class="meta">
{{#link-to 'forgotten' class="forgotten-password"}}Forgotten password?{{/link-to}}
</section>