mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 05:11:34 +02:00
23 lines
618 B
JavaScript
23 lines
618 B
JavaScript
const logger = require('logger-sharelatex')
|
|
|
|
module.exports = {
|
|
forbidden(req, res, message = 'restricted', info = {}) {
|
|
res.status(403)
|
|
switch (req.accepts(['html', 'json'])) {
|
|
case 'html':
|
|
return res.render('user/restricted', { title: 'restricted' })
|
|
case 'json':
|
|
const fullInfo = { message, ...info }
|
|
if (info.message) {
|
|
logger.warn(
|
|
info,
|
|
`http error info shouldn't contain a 'message' field, will be overridden`
|
|
)
|
|
}
|
|
return res.json(fullInfo)
|
|
default:
|
|
return res.send('restricted')
|
|
}
|
|
}
|
|
}
|