mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
a258e3d881
issue TryGhost/Ghost#7452, requires TryGhost/Ghost#7451 - use a `ghostOAuth` config flag to switch between the old-style per-install auth and centralized OAuth auth based on config provided by the server - add OAuth flows for: - setup - sign-in - sign-up - re-authenticate - add custom `oauth-ghost` authenticator to support our custom data structure - add test helpers to stub successful/failed oauth authentication - hide change password form if using OAuth (temporary - a way to change password via oauth provider will be added later)
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import BaseValidator from './base';
|
|
|
|
export default BaseValidator.extend({
|
|
properties: ['name', 'email', 'password'],
|
|
|
|
name(model) {
|
|
let usingOAuth = model.get('config.ghostOAuth');
|
|
let name = model.get('name');
|
|
|
|
if (!usingOAuth && !validator.isLength(name, 1)) {
|
|
model.get('errors').add('name', 'Please enter a name.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
email(model) {
|
|
let usingOAuth = model.get('config.ghostOAuth');
|
|
let email = model.get('email');
|
|
|
|
if (usingOAuth) {
|
|
return;
|
|
}
|
|
|
|
if (validator.empty(email)) {
|
|
model.get('errors').add('email', 'Please enter an email.');
|
|
this.invalidate();
|
|
} else if (!validator.isEmail(email)) {
|
|
model.get('errors').add('email', 'Invalid Email.');
|
|
this.invalidate();
|
|
}
|
|
},
|
|
|
|
password(model) {
|
|
let usingOAuth = model.get('config.ghostOAuth');
|
|
let password = model.get('password');
|
|
|
|
if (!usingOAuth && !validator.isLength(password, 8)) {
|
|
model.get('errors').add('password', 'Password must be at least 8 characters long');
|
|
this.invalidate();
|
|
}
|
|
}
|
|
});
|