proxyAuth: redirect to /login when logout

part of #753
This commit is contained in:
Girish Ramakrishnan
2020-12-19 12:30:06 -08:00
parent eff9d378e5
commit 85d37233a2

View File

@@ -160,9 +160,19 @@ function authorize(req, res, next) {
});
}
function logoutPage(req, res) {
res.clearCookie('authToken');
res.redirect(302, '/'); // do not redirect to '/login' as it may not be protected
function logoutPage(req, res, next) {
const appId = req.headers['x-app-id'] || '';
if (!appId) return next(new HttpError(503, 'Nginx misconfiguration'));
apps.get(appId, function (error, app) {
if (error) return next(new HttpError(503, error.message));
res.clearCookie('authToken');
// when we have no path, redirect to the login page. we cannot redirect to '/' because browsers will immediately serve up the cached page
// if a path is set, we can assume '/' is a public page
res.redirect(302, app.manifest.addons.proxyAuth.path ? '/' : '/login');
});
}
function logout(req, res, next) {