2016-05-24 15:06:59 +03:00
|
|
|
import NewUserValidator from 'ghost-admin/validators/new-user';
|
2014-07-25 23:17:16 +04:00
|
|
|
|
2015-08-19 14:55:40 +03:00
|
|
|
export default NewUserValidator.create({
|
2016-09-30 14:43:40 +03:00
|
|
|
properties: ['name', 'email', 'password', 'blogTitle', 'session'],
|
2014-06-25 16:12:48 +04:00
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
blogTitle(model) {
|
|
|
|
let blogTitle = model.get('blogTitle');
|
2014-06-30 07:43:25 +04:00
|
|
|
|
2015-06-07 06:19:19 +03:00
|
|
|
if (!validator.isLength(blogTitle, 1)) {
|
|
|
|
model.get('errors').add('blogTitle', 'Please enter a blog title.');
|
|
|
|
this.invalidate();
|
|
|
|
}
|
2016-09-30 14:43:40 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2014-06-25 16:12:48 +04:00
|
|
|
}
|
2015-06-07 06:19:19 +03:00
|
|
|
});
|