mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 19:52:01 +03:00
72156c7f89
fixes #3072 - Change router to handle /ember/setup/ - Adjust doSignup to also handle setup - Adjust tests and add new where necessary - Add setup controller, setup validation, setup route - Adjust casper emberSetup to handle new setup
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;
|
|
|
|
// @TODO This should call closePassive() to only close passive notifications
|
|
self.notifications.closeAll();
|
|
|
|
this.toggleProperty('submitting');
|
|
this.validate({ format: false }).then(function () {
|
|
ajax({
|
|
url: self.get('ghostPaths').adminUrl('setup'),
|
|
type: 'POST',
|
|
headers: {
|
|
'X-CSRF-Token': self.get('csrf')
|
|
},
|
|
data: self.getProperties('blogTitle', 'name', 'email', 'password')
|
|
}).then(function (resp) {
|
|
self.toggleProperty('submitting');
|
|
if (resp && resp.userData) {
|
|
self.store.pushPayload({ users: [resp.userData]});
|
|
self.store.find('user', resp.userData.id).then(function (user) {
|
|
self.send('signedIn', user);
|
|
self.notifications.clear();
|
|
self.transitionToRoute('posts');
|
|
});
|
|
} else {
|
|
self.transitionToRoute('setup');
|
|
}
|
|
}, function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showAPIError(resp);
|
|
});
|
|
}, function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SetupController;
|