Ghost/ghost/admin/routes/signup.js
Jacob Gable 0229a127fe Implement signup in Ember
Closes #2410

- Add signup action that posts to signup endpoint
- Fix nav bar showing on signup page
- Fix image link when a user hasn't set their image yet
- Redirect to the ember/signin page if requesting an ember page
2014-05-23 12:17:28 -05:00

48 lines
1.4 KiB
JavaScript

import ajax from 'ghost/utils/ajax';
import styleBody from 'ghost/mixins/style-body';
var SignupRoute = Ember.Route.extend(styleBody, {
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.send('signedIn', resp.userData);
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;