1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

support object id's (#390)

refs TryGhost/Ghost#7494

- remove id validation
This commit is contained in:
Katharina Irrgang 2016-11-14 11:53:15 +01:00 committed by Kevin Ansfield
parent 6d89e58a62
commit cd1fe4aeea
2 changed files with 12 additions and 33 deletions

View file

@ -1,8 +1,6 @@
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import base from 'ghost-admin/mixins/editor-base-route';
import isNumber from 'ghost-admin/utils/isNumber';
import isFinite from 'ghost-admin/utils/isFinite';
export default AuthenticatedRoute.extend(base, {
titleToken: 'Editor',
@ -14,20 +12,13 @@ export default AuthenticatedRoute.extend(base, {
},
model(params) {
let postId,
query;
postId = Number(params.post_id);
if (!isNumber(postId) || !isFinite(postId) || postId % 1 !== 0 || postId <= 0) {
return this.transitionTo('error404', `editor/${params.post_id}`);
}
query = {
id: postId,
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
let query = {
id: params.post_id,
status: 'all',
staticPages: 'all'
};
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
return this.store.query('post', query).then((records) => {
let post = records.get('firstObject');

View file

@ -1,32 +1,20 @@
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import ShortcutsRoute from 'ghost-admin/mixins/shortcuts-route';
import isNumber from 'ghost-admin/utils/isNumber';
import isFinite from 'ghost-admin/utils/isFinite';
export default AuthenticatedRoute.extend(ShortcutsRoute, {
model(params) {
let post,
postId,
query;
/* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
postId = Number(params.post_id);
if (!isNumber(postId) || !isFinite(postId) || postId % 1 !== 0 || postId <= 0) {
return this.transitionTo('error404', params.post_id);
}
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
post = this.store.peekRecord('post', postId);
if (post) {
return post;
}
query = {
id: postId,
let post = this.store.peekRecord('post', params.post_id);
let query = {
id: params.post_id,
status: 'all',
staticPages: 'all'
};
/* jscs:enable requireCamelCaseOrUpperCaseIdentifiers */
if (post) {
return post;
}
return this.store.query('post', query).then((records) => {
let post = records.get('firstObject');