mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Merge pull request #5775 from ErisDS/signin-validation
Add email validation back to signin
This commit is contained in:
commit
e21b4b9f70
2 changed files with 9 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
|||
<form id="login" class="gh-signin" method="post" novalidate="novalidate">
|
||||
{{#gh-form-group errors=model.errors hasValidated=hasValidated property="identification"}}
|
||||
<span class="input-icon icon-mail">
|
||||
{{gh-trim-focus-input class="gh-input email" type="email" placeholder="Email Address" name="identification" autocapitalize="off" autocorrect="off" tabindex="1" value=model.identification}}
|
||||
{{gh-trim-focus-input class="gh-input email" type="email" placeholder="Email Address" name="identification" autocapitalize="off" autocorrect="off" tabindex="1" focusOut=(action "validate" "identification") value=model.identification}}
|
||||
</span>
|
||||
{{/gh-form-group}}
|
||||
{{#gh-form-group errors=model.errors hasValidated=hasValidated property="password"}}
|
||||
|
|
|
@ -2,12 +2,13 @@ import BaseValidator from './base';
|
|||
|
||||
var SigninValidator = BaseValidator.create({
|
||||
properties: ['identification', 'signin', 'forgotPassword'],
|
||||
invalidMessage: 'Email address is not valid',
|
||||
|
||||
identification: function (model) {
|
||||
var id = model.get('identification');
|
||||
|
||||
if (!validator.empty(id) && !validator.isEmail(id)) {
|
||||
model.get('errors').add('identification', 'Invalid email');
|
||||
model.get('errors').add('identification', this.get('invalidMessage'));
|
||||
this.invalidate();
|
||||
}
|
||||
},
|
||||
|
@ -23,6 +24,11 @@ var SigninValidator = BaseValidator.create({
|
|||
this.invalidate();
|
||||
}
|
||||
|
||||
if (!validator.empty(id) && !validator.isEmail(id)) {
|
||||
model.get('errors').add('identification', this.get('invalidMessage'));
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
if (validator.empty(password)) {
|
||||
model.get('errors').add('password', 'Please enter a password');
|
||||
this.invalidate();
|
||||
|
@ -35,7 +41,7 @@ var SigninValidator = BaseValidator.create({
|
|||
model.get('errors').clear();
|
||||
|
||||
if (validator.empty(id) || !validator.isEmail(id)) {
|
||||
model.get('errors').add('identification', 'Invalid email');
|
||||
model.get('errors').add('identification', this.get('invalidMessage'));
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue