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
|
// Secure API key storage with additional client-side security and debugging
|
||||||
res.send(`
|
res.send(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Secure Auto Login</title>
|
<title>Secure Auto Login</title>
|
||||||
<meta name="robots" content="noindex">
|
<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="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'nonce-${nonce}'">
|
||||||
<meta http-equiv="refresh" content="5;url=/">
|
<meta http-equiv="refresh" content="2;url=/">
|
||||||
<style>
|
<style>
|
||||||
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #111827; font-family: 'Arial', sans-serif; }
|
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%; }
|
.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; }
|
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; }
|
.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); } }
|
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="notification">
|
<div class="notification">
|
||||||
<span class="spinner"></span>
|
<span class="spinner"></span>
|
||||||
<h1>Securely logging in...</h1>
|
<h1>Securely logging in...</h1>
|
||||||
</div>
|
</div>
|
||||||
<script nonce="${nonce}">
|
<script nonce="${nonce}">
|
||||||
(function() {
|
(function() {
|
||||||
console.log('Auto-login script started');
|
console.log('Auto-login script started');
|
||||||
const apiKey = '${sanitizeHtml(linkData.apiKey)}';
|
const apiKey = '${sanitizeHtml(linkData.apiKey)}';
|
||||||
console.log('API key retrieved');
|
console.log('API key retrieved');
|
||||||
try {
|
try {
|
||||||
localStorage.setItem('apiKey', apiKey);
|
localStorage.setItem('apiKey', apiKey);
|
||||||
console.log('API key stored in localStorage');
|
console.log('API key stored in localStorage');
|
||||||
sessionStorage.setItem('sessionTimestamp', Date.now());
|
sessionStorage.setItem('sessionTimestamp', Date.now());
|
||||||
console.log('Session timestamp stored');
|
console.log('Session timestamp stored');
|
||||||
|
setTimeout(() => {
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
console.log('Redirect initiated to /');
|
console.log('Redirect initiated to /');
|
||||||
} catch (e) {
|
}, 2000);
|
||||||
console.error('Storage error:', e.message);
|
} catch (e) {
|
||||||
|
console.error('Storage error:', e.message);
|
||||||
|
setTimeout(() => {
|
||||||
window.location.href = '${encodeURI(process.env.AUTO_LOGIN_REDIRECT_URL)}';
|
window.location.href = '${encodeURI(process.env.AUTO_LOGIN_REDIRECT_URL)}';
|
||||||
console.log('Fallback redirect initiated to AUTO_LOGIN_REDIRECT_URL');
|
console.log('Fallback redirect initiated to AUTO_LOGIN_REDIRECT_URL');
|
||||||
}
|
}, 2000);
|
||||||
})();
|
}
|
||||||
</script>
|
})();
|
||||||
</body>
|
</script>
|
||||||
</html>
|
</body>
|
||||||
`);
|
</html>
|
||||||
|
`);
|
||||||
});
|
});
|
||||||
}
|
}
|
Reference in New Issue
Block a user