mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03:00
Fixed 500 errors when accessing editor routes without post/page
no issue
This commit is contained in:
parent
8514372dad
commit
856c4000c8
@ -14,13 +14,20 @@ export default AuthenticatedRoute.extend({
|
||||
}
|
||||
},
|
||||
|
||||
model(params) {
|
||||
model(params, transition) {
|
||||
let {type: modelName, post_id} = params;
|
||||
|
||||
if (!['post', 'page'].includes(modelName)) {
|
||||
let path = transition.intent.url.replace(/^\//, '');
|
||||
return this.replaceWith('error404', {path, status: 404});
|
||||
}
|
||||
|
||||
let query = {
|
||||
id: params.post_id,
|
||||
id: post_id,
|
||||
status: 'all'
|
||||
};
|
||||
|
||||
return this.store.query(params.type, query)
|
||||
return this.store.query(modelName, query)
|
||||
.then(records => records.get('firstObject'));
|
||||
},
|
||||
|
||||
|
@ -1,9 +1,16 @@
|
||||
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
||||
|
||||
export default AuthenticatedRoute.extend({
|
||||
model(params) {
|
||||
model(params, transition) {
|
||||
let {type: modelName} = params;
|
||||
|
||||
if (!['post','page'].includes(modelName)) {
|
||||
let path = transition.intent.url.replace(/^\//, '');
|
||||
return this.replaceWith('error404', {path, status: 404});
|
||||
}
|
||||
|
||||
return this.get('session.user').then(user => (
|
||||
this.store.createRecord(params.type, {authors: [user]})
|
||||
this.store.createRecord(modelName, {authors: [user]})
|
||||
));
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user