Ghost/ghost/admin/app/validators/reset.js
Kevin Ansfield 042aecb7f6 Switch from embor-browserify to ember-auto-import
no issue
- minor reduction in build size. Before/after:
  - `vendor.min.js 3.32 MB (710.66 KB gzipped)`
  - `vendor.min.js 3.29 MB (706 KB gzipped)`
2019-01-22 13:09:38 +00:00

29 lines
901 B
JavaScript

import BaseValidator from './base';
import PasswordValidatorMixin from './mixins/password';
import validator from 'validator';
import {isBlank} from '@ember/utils';
const resetValidator = BaseValidator.extend(PasswordValidatorMixin, {
init() {
this.properties = this.properties || ['newPassword'];
this._super(...arguments);
},
newPassword(model) {
let p1 = model.get('newPassword');
let p2 = model.get('ne2Password');
if (isBlank(p1)) {
model.get('errors').add('newPassword', 'Please enter a password.');
this.invalidate();
} else if (!validator.equals(p1, p2 || '')) {
model.get('errors').add('ne2Password', 'The two new passwords don\'t match.');
this.invalidate();
}
this.passwordValidation(model, p1, 'newPassword');
}
});
export default resetValidator.create();