Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
const HttpStatusCodes = require("http-status-codes");
module.exports = {
// Status codes where we want to redirect the user
redirect: {
[HttpStatusCodes.MOVED_PERMANENTLY]: true,
[HttpStatusCodes.MOVED_TEMPORARILY]: true,
[HttpStatusCodes.PERMANENT_REDIRECT]: true,
[HttpStatusCodes.TEMPORARY_REDIRECT]: true
}
};
return function(req, res, next){
if (req.session && req.session.st){
// refresh the expiration if ssout
if (req.ssout) {
req.sessionStore.set(req.session.st, req.session.id);
}
next();
return;
}
options.pathname = options.paths.login;
options.query = options.query || {};
options.query.service = origin(req);
res.redirect(HttpStatus.TEMPORARY_REDIRECT, url.format(options));
};
};
export const TemporaryRedirect = (url: string): Result =>
Redirect(url, HttpStatusCodes.TEMPORARY_REDIRECT);
function redirectToLogin(options, req, res){
options.pathname = options.paths.login;
options.query = {};
options.query.service = origin(req);
res.redirect(HttpStatus.TEMPORARY_REDIRECT, url.format(options));
}
export function temporaryRedirect(arg1: T | string | Wrapper, arg2?: string): T {
return answer(HTTP.TEMPORARY_REDIRECT, arg1, arg2);
}