Implement 404 for documents

This commit is contained in:
Jori Lallo
2016-08-03 15:36:50 +03:00
parent 80edf4a693
commit 5b3ed8b1f9
2 changed files with 8 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import _ from 'lodash';
import { browserHistory } from 'react-router';
import stores from 'stores';
import constants from '../constants';
@@ -57,6 +58,11 @@ class ApiClient {
return response;
}
// Handle 404
if (response.status === 404) {
return browserHistory.push('/404');
}
// Handle 401, log out user
if (response.status === 401) {
stores.user.logout();

View File

@@ -22,6 +22,8 @@ router.post('documents.info', auth({ require: false }), async (ctx) => {
},
});
if (!document) throw httpErrors.NotFound();
// Don't expose private documents outside the team
if (document.private) {
if (!ctx.state.user) throw httpErrors.NotFound();
@@ -39,8 +41,6 @@ router.post('documents.info', auth({ require: false }), async (ctx) => {
data: await presentDocument(document),
};
}
if (!document) throw httpErrors.NotFound();
});
router.post('documents.search', auth(), async (ctx) => {