0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Redirect to error404 when user not found.

Closes #3459.
This commit is contained in:
Robert Jackson 2014-07-30 17:42:46 -04:00
parent 820459e625
commit 356f9525d8

View file

@ -1,11 +1,18 @@
var SettingsUserRoute = Ember.Route.extend({ var SettingsUserRoute = Ember.Route.extend({
model: function (params) { model: function (params) {
var self = this;
// TODO: Make custom user adapter that uses /api/users/:slug endpoint // TODO: Make custom user adapter that uses /api/users/:slug endpoint
// return this.store.find('user', { slug: params.slug }); // return this.store.find('user', { slug: params.slug });
// Instead, get all the users and then find by slug // Instead, get all the users and then find by slug
return this.store.find('user').then(function (result) { return this.store.find('user').then(function (result) {
return result.findBy('slug', params.slug); var user = result.findBy('slug', params.slug);
if (!user) {
return self.transitionTo('error404', 'settings/users/' + params.slug);
}
return user;
}); });
}, },