mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 09:52:09 +03:00
42a1d55858
Ref #2413 - Remove fixture and use actual API - Store and send down actual logged in user data - Refactor isLoggedIn to use computed property on application - After signin, update user data in dependency container - Add CSRF to all routes and controllers via initializer - Update authenticated route to check for user.isLoggedIn - Add notifications for signin error - Add notifications.showAPIError helper - Add plumbing for refreshless signup to doSignUp in admin controller
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
var ApplicationRoute = Ember.Route.extend({
|
|
actions: {
|
|
signedIn: function (user) {
|
|
this.container.lookup('user:current').setProperties(user);
|
|
},
|
|
|
|
signedOut: function () {
|
|
this.container.lookup('user:current').setProperties({
|
|
id: null,
|
|
name: null,
|
|
image: null
|
|
});
|
|
},
|
|
|
|
openModal: function (modalName, model) {
|
|
modalName = 'modals/' + modalName;
|
|
// We don't always require a modal to have a controller
|
|
// so we're skipping asserting if one exists
|
|
if (this.controllerFor(modalName, true)) {
|
|
this.controllerFor(modalName).set('model', model);
|
|
}
|
|
return this.render(modalName, {
|
|
into: 'application',
|
|
outlet: 'modal'
|
|
});
|
|
},
|
|
|
|
closeModal: function () {
|
|
return this.disconnectOutlet({
|
|
outlet: 'modal',
|
|
parentView: 'application'
|
|
});
|
|
},
|
|
|
|
handleErrors: function (errors) {
|
|
this.notifications.clear();
|
|
errors.forEach(function (errorObj) {
|
|
this.notifications.showError(errorObj.message || errorObj);
|
|
|
|
if (errorObj.hasOwnProperty('el')) {
|
|
errorObj.el.addClass('input-error');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default ApplicationRoute; |