mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
4c72c318d5
closes #2855 , closes #2848 - New mixin that utilizes NProgress for displaying a loading indictor for all routes who's model issue a "loading" event (aka: when requesting data from the server during a route change). - Also removing (the now unnecessary) "loading" template.
50 lines
1.7 KiB
JavaScript
50 lines
1.7 KiB
JavaScript
import ajax from 'ghost/utils/ajax';
|
|
import styleBody from 'ghost/mixins/style-body';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
|
|
var SignupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
|
classNames: ['ghost-signup'],
|
|
|
|
name: null,
|
|
email: null,
|
|
password: null,
|
|
|
|
actions: {
|
|
signup: function () {
|
|
var self = this,
|
|
controller = this.get('controller'),
|
|
data = controller.getProperties('name', 'email', 'password');
|
|
|
|
// TODO: Validate data
|
|
|
|
if (data.name && data.email && data.password) {
|
|
ajax({
|
|
url: '/ghost/signup/',
|
|
type: 'POST',
|
|
headers: {
|
|
'X-CSRF-Token': this.get('csrf')
|
|
},
|
|
data: data
|
|
}).then(function (resp) {
|
|
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.transitionTo('posts');
|
|
});
|
|
} else {
|
|
self.transitionTo('signin');
|
|
}
|
|
}, function (resp) {
|
|
self.notifications.showAPIError(resp);
|
|
});
|
|
} else {
|
|
this.notifications.showError('Must provide name, email and password');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SignupRoute;
|