mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 02:06:29 -05:00
d389f45818
This patch fixes the currently broken redirect on login when people try to access a site they have no access to, they are redirected to the main page to log in. After a successful login they should be redirected to the original note, but instead are redirect to the index page again. This aptch fixes the typo that causes the behavior and brings people back to the note they edited. Thanks to @clvs7-gh on Github[1], who submitted the patch via email. On their behalf I hereby submit the change. [1]: https://github.com/clvs7-gh Note: I had to ajust this patch to work properly. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const config = require('./config')
|
|
|
|
module.exports = {
|
|
errorForbidden: function (res) {
|
|
const { req } = res
|
|
if (req.user) {
|
|
responseError(res, '403', 'Forbidden', 'oh no.')
|
|
} else {
|
|
if (!req.session) req.session = {}
|
|
if (req.originalUrl !== '/403') {
|
|
req.session.returnTo = config.serverURL + (req.originalUrl || '/')
|
|
req.flash('error', 'You are not allowed to access this page. Maybe try logging in?')
|
|
}
|
|
res.redirect(config.serverURL + '/')
|
|
}
|
|
},
|
|
errorNotFound: function (res) {
|
|
responseError(res, '404', 'Not Found', 'oops.')
|
|
},
|
|
errorBadRequest: function (res) {
|
|
responseError(res, '400', 'Bad Request', 'something not right.')
|
|
},
|
|
errorTooLong: function (res) {
|
|
responseError(res, '413', 'Payload Too Large', 'Shorten your note!')
|
|
},
|
|
errorInternalError: function (res) {
|
|
responseError(res, '500', 'Internal Error', 'wtf.')
|
|
},
|
|
errorServiceUnavailable: function (res) {
|
|
res.status(503).send('I\'m busy right now, try again later.')
|
|
}
|
|
}
|
|
|
|
function responseError (res, code, detail, msg) {
|
|
res.status(code).render('error.ejs', {
|
|
title: code + ' ' + detail + ' ' + msg,
|
|
code: code,
|
|
detail: detail,
|
|
msg: msg,
|
|
opengraph: []
|
|
})
|
|
}
|