export function getLoginResponse()

in src/uiHtml.ts [137:162]


export function getLoginResponse(req: express.Request): string {
	const userHost = req.get('host') ?? '';
	let returnUrl = `${req.protocol}://${userHost}${req.originalUrl}`;
	if (returnUrl.includes('localhost')) {
		returnUrl =
			'https://image-url-signing-service.local.dev-gutools.co.uk/';
	}
	const loginDomain = getLoginUrl(getStage());
	const encodedReturnUrl = encodeURIComponent(returnUrl);
	const loginUrl = `${loginDomain}/login?returnUrl=${encodedReturnUrl}`;
	const loginRedirectHTML = `
<!DOCTYPE html>
<html>
	<head>
		<title>Image URL Signing Service - Not logged in</title>
	</head>
	<body>
		<h1>Image URL Signing Service</h1>
		<p>You must be logged in to use the Image URL signing service.
			<a href="${loginUrl}">Click here to login</a>
		</p>
	</body>
</html>
`;
	return loginRedirectHTML;
}