mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
786e0ac9c5
no issue - if a plain native class instance with tracked properties is validated against the `ValidationEngine` and it's associated validators would cause errors by assuming that the instance has a `.get()` method - updated all model access in `ValidationEngine` and the validators to use direct property access which works for both native class and `EmberObject` instances
29 lines
873 B
JavaScript
29 lines
873 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.newPassword;
|
|
let p2 = model.ne2Password;
|
|
|
|
if (isBlank(p1)) {
|
|
model.errors.add('newPassword', 'Please enter a password.');
|
|
this.invalidate();
|
|
} else if (!validator.equals(p1, p2 || '')) {
|
|
model.errors.add('ne2Password', 'The two new passwords don\'t match.');
|
|
this.invalidate();
|
|
}
|
|
|
|
this.passwordValidation(model, p1, 'newPassword');
|
|
}
|
|
});
|
|
|
|
export default resetValidator.create();
|