Skip to content

Instantly share code, notes, and snippets.

@akhilesh26
Created November 14, 2017 21:41
Show Gist options
  • Save akhilesh26/2c88065a52556d4fa91e1063a35de78b to your computer and use it in GitHub Desktop.
Save akhilesh26/2c88065a52556d4fa91e1063a35de78b to your computer and use it in GitHub Desktop.
router.get('/reindex', auth.isAuthenticated, (req, res) => {
const {orm} = req.app.locals;
const indexPromise = new Promise((resolve) => {
// TODO: This is hacky, and we should replace it once we switch to SOLR.
const trustedUsers = ['Leftmost Cat', 'LordSputnik', 'mastcoder'];
const NO_MATCH = -1;
if (trustedUsers.indexOf(req.user.name) === NO_MATCH) {
throw new error.PermissionDeniedError(null, req);
}
resolve();
})
.then(() => search.generateIndex(orm))
.then(() => ({success: true}));
handler.sendPromiseResult(res, indexPromise);
});
{"error":"You do not have permission to access this page"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment