mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
1af5eb6248
fixes #3105, refs #3012 - Add additional closeAll() calls where users interact with data
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import ajax from 'ghost/utils/ajax';
|
|
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
|
|
var SignupController = Ember.ObjectController.extend(ValidationEngine, {
|
|
name: null,
|
|
email: null,
|
|
password: null,
|
|
submitting: false,
|
|
|
|
// ValidationEngine settings
|
|
validationType: 'signup',
|
|
|
|
actions: {
|
|
signup: 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('signup'),
|
|
type: 'POST',
|
|
headers: {
|
|
'X-CSRF-Token': self.get('csrf')
|
|
},
|
|
data: self.getProperties('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.transitionToRoute('posts');
|
|
});
|
|
} else {
|
|
self.transitionToRoute('signin');
|
|
}
|
|
}, function (resp) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showAPIError(resp);
|
|
});
|
|
}, function (errors) {
|
|
self.toggleProperty('submitting');
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SignupController;
|