mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
0229a127fe
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
48 lines
1.4 KiB
JavaScript
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;
|