Ghost/ghost/admin/app/validators/setup.js
Kevin Ansfield a258e3d881 Ghost.org OAuth support (#278)
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)
2016-09-30 13:43:40 +02:00

26 lines
837 B
JavaScript

import NewUserValidator from 'ghost-admin/validators/new-user';
export default NewUserValidator.create({
properties: ['name', 'email', 'password', 'blogTitle', 'session'],
blogTitle(model) {
let blogTitle = model.get('blogTitle');
if (!validator.isLength(blogTitle, 1)) {
model.get('errors').add('blogTitle', 'Please enter a blog title.');
this.invalidate();
}
},
session(model) {
let usingOAuth = model.get('config.ghostOAuth');
let isAuthenticated = model.get('session.isAuthenticated');
if (usingOAuth && !isAuthenticated) {
model.get('errors').add('session', 'Please connect a Ghost.org account before continuing');
model.get('hasValidated').pushObject('session');
this.invalidate();
}
}
});