Implement 404 for documents
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { browserHistory } from 'react-router';
|
||||||
import stores from 'stores';
|
import stores from 'stores';
|
||||||
|
|
||||||
import constants from '../constants';
|
import constants from '../constants';
|
||||||
@@ -57,6 +58,11 @@ class ApiClient {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle 404
|
||||||
|
if (response.status === 404) {
|
||||||
|
return browserHistory.push('/404');
|
||||||
|
}
|
||||||
|
|
||||||
// Handle 401, log out user
|
// Handle 401, log out user
|
||||||
if (response.status === 401) {
|
if (response.status === 401) {
|
||||||
stores.user.logout();
|
stores.user.logout();
|
||||||
|
|||||||
@@ -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
|
// Don't expose private documents outside the team
|
||||||
if (document.private) {
|
if (document.private) {
|
||||||
if (!ctx.state.user) throw httpErrors.NotFound();
|
if (!ctx.state.user) throw httpErrors.NotFound();
|
||||||
@@ -39,8 +41,6 @@ router.post('documents.info', auth({ require: false }), async (ctx) => {
|
|||||||
data: await presentDocument(document),
|
data: await presentDocument(document),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!document) throw httpErrors.NotFound();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('documents.search', auth(), async (ctx) => {
|
router.post('documents.search', auth(), async (ctx) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user