add a small delay when logging in to reduce confusion
This commit is contained in:
@ -255,47 +255,51 @@ export function handleAutoLogin(req, res) {
|
||||
|
||||
// Secure API key storage with additional client-side security and debugging
|
||||
res.send(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Secure Auto Login</title>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'nonce-${nonce}'">
|
||||
<meta http-equiv="refresh" content="5;url=/">
|
||||
<style>
|
||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #111827; font-family: 'Arial', sans-serif; }
|
||||
.notification { background-color: #1f2937; color: white; padding: 16px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); max-width: 400px; width: 100%; }
|
||||
h1 { font-size: 2.25em; color: white; text-align: center; margin: 0; }
|
||||
.spinner { border: 4px solid rgba(255, 255, 255, 0.3); border-top: 4px solid #ffffff; border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; }
|
||||
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="notification">
|
||||
<span class="spinner"></span>
|
||||
<h1>Securely logging in...</h1>
|
||||
</div>
|
||||
<script nonce="${nonce}">
|
||||
(function() {
|
||||
console.log('Auto-login script started');
|
||||
const apiKey = '${sanitizeHtml(linkData.apiKey)}';
|
||||
console.log('API key retrieved');
|
||||
try {
|
||||
localStorage.setItem('apiKey', apiKey);
|
||||
console.log('API key stored in localStorage');
|
||||
sessionStorage.setItem('sessionTimestamp', Date.now());
|
||||
console.log('Session timestamp stored');
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Secure Auto Login</title>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'nonce-${nonce}'">
|
||||
<meta http-equiv="refresh" content="2;url=/">
|
||||
<style>
|
||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #111827; font-family: 'Arial', sans-serif; }
|
||||
.notification { background-color: #1f2937; color: white; padding: 16px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); max-width: 400px; width: 100%; }
|
||||
h1 { font-size: 2.25em; color: white; text-align: center; margin: 0; }
|
||||
.spinner { border: 4px solid rgba(255, 255, 255, 0.3); border-top: 4px solid #ffffff; border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; }
|
||||
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="notification">
|
||||
<span class="spinner"></span>
|
||||
<h1>Securely logging in...</h1>
|
||||
</div>
|
||||
<script nonce="${nonce}">
|
||||
(function() {
|
||||
console.log('Auto-login script started');
|
||||
const apiKey = '${sanitizeHtml(linkData.apiKey)}';
|
||||
console.log('API key retrieved');
|
||||
try {
|
||||
localStorage.setItem('apiKey', apiKey);
|
||||
console.log('API key stored in localStorage');
|
||||
sessionStorage.setItem('sessionTimestamp', Date.now());
|
||||
console.log('Session timestamp stored');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/';
|
||||
console.log('Redirect initiated to /');
|
||||
} catch (e) {
|
||||
console.error('Storage error:', e.message);
|
||||
}, 2000);
|
||||
} catch (e) {
|
||||
console.error('Storage error:', e.message);
|
||||
setTimeout(() => {
|
||||
window.location.href = '${encodeURI(process.env.AUTO_LOGIN_REDIRECT_URL)}';
|
||||
console.log('Fallback redirect initiated to AUTO_LOGIN_REDIRECT_URL');
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
}, 2000);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user