mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
e22e1f340b
closes #3136 - moved setup to authentication API - added `POST /ghost/api/v0.1/authentication/setup` to execute the setup process - added `GET /ghost/api/v0.1/authentication/setup` to check if blog is already set up (needed for #3145) - removed unused methods from api/users.js
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
import ajax from 'ghost/utils/ajax';
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
|
|
var SetupController = Ember.ObjectController.extend(ValidationEngine, {
|
|
blogTitle: null,
|
|
name: null,
|
|
email: null,
|
|
password: null,
|
|
submitting: false,
|
|
|
|
// ValidationEngine settings
|
|
validationType: 'setup',
|
|
|
|
actions: {
|
|
setup: function () {
|
|
var self = this,
|
|
data = self.getProperties('blogTitle', 'name', 'email', 'password');
|
|
|
|
self.notifications.closePassive();
|
|
|
|
this.toggleProperty('submitting');
|
|
this.validate({ format: false }).then(function () {
|
|
ajax({
|
|
url: self.get('ghostPaths').apiUrl('authentication', 'setup'),
|
|
type: 'POST',
|
|
data: {
|
|
setup: [{
|
|
name: data.name,
|
|
email: data.email,
|
|
password: data.password,
|
|
blogTitle: data.blogTitle
|
|
}]
|
|
}
|
|
}).then(function () {
|
|
self.get('session').authenticate('ember-simple-auth-authenticator:oauth2-password-grant', {
|
|
identification: self.get('email'),
|
|
password: self.get('password')
|
|
}).then(function () {
|
|
self.send('signedIn');
|
|
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
|
|
});
|
|
}, function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showAPIError(resp);
|
|
});
|
|
}, function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SetupController;
|