mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
5abeadf80d
Ref #2699 - Introduce ember data dependency - Add loadInitializers and refactor most initializers into one combined - Add Post ember data model - Refactor generateSlug to use title of post and ghostPaths - Refactor post controller to not reference model.property everywhere - Use RESTAdapter for posts, users and tags - Setup author and tag relations in Post model - Fix broken API calls by adding CSRF header - Add initiaizer for csrf value - Use actual User model for current user initializer - Add action for setting featured post, test with actual api call - Fix the sending of UUID's up to the server - Refactor current-user to use ember-data store - If a user is preloaded in the application, use pushPayload to put it in the store - Do a lookup on the store to get an actual User model for injection - Fix posts/post controllerName in route/new.js - Alter signup process to push user into ember data store
49 lines
1.6 KiB
JavaScript
49 lines
1.6 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.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;
|