Mode2Test/AuthAndToken: assume tokens always fresh with background refresh; fix jobs API to use correct collection; align Home UI to Mode1 (exact fields, styling, strict Active dot); add full-field IndexedDB cache w/ pagination; remove progress bar; dev TLS bypass; rebuild bundles

This commit is contained in:
2026-01-17 20:20:24 +00:00
parent eed8552282
commit d77fa4b817
21 changed files with 5964 additions and 205 deletions
+21 -7
View File
@@ -48,14 +48,23 @@
console.log('[Auth] Graph token found:', !!graphToken);
// Send to backend to store
await fetch('/api/auth/login', {
const saveResponse = await fetch('/api/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ pbToken: authData.token, graphToken: graphToken || undefined })
});
// Redirect to app immediately
window.location.href = '/index.html';
if (!saveResponse.ok) {
throw new Error('Failed to save tokens to backend');
}
console.log('[Auth] Tokens saved to backend, redirecting to home');
// Clear PocketBase local storage to avoid conflicts
pb.authStore.clear();
// Redirect to home page
window.location.href = '/home.html';
} catch (err) {
document.getElementById('error').textContent = err.message || 'Login failed';
document.getElementById('error').classList.remove('hidden');
@@ -64,10 +73,15 @@
}
}
// Check if already logged in
if (pb.authStore.isValid) {
window.location.href = '/index.html';
}
// Check if already logged in via backend only
fetch('/api/auth/status')
.then(res => res.json())
.then(data => {
if (data.authenticated) {
window.location.href = '/home.html';
}
})
.catch(() => {});
</script>
</body>
</html>