many edits

This commit is contained in:
2025-12-19 22:55:48 +00:00
parent 56e1131622
commit 94e5079a60
3 changed files with 244 additions and 34 deletions
+12 -1
View File
@@ -49,6 +49,7 @@
const errorEl = document.getElementById('error');
const userInfo = document.getElementById('userInfo');
const continueBtn = document.getElementById('continueBtn');
const GRAPH_REAUTH_FLAG = 'graphReauthAttempted';
function goToIndex() {
window.location.href = 'index.html';
@@ -100,15 +101,25 @@
const email = authData?.meta?.rawUser?.email || authData?.record?.email || pb.authStore.model?.email || 'Not available';
const graphToken = extractGraphToken(authData);
console.log('Extracted Graph token:', graphToken ? graphToken.substring(0, 30) + '...' : 'NOT FOUND');
if (graphToken) localStorage.setItem(GRAPH_TOKEN_KEY, graphToken);
if (graphToken) {
localStorage.setItem(GRAPH_TOKEN_KEY, graphToken);
localStorage.removeItem(GRAPH_REAUTH_FLAG);
}
showAuthedUI(displayName, email);
}
(async () => {
const params = new URLSearchParams(window.location.search);
const reauth = params.get('reauth') === '1';
if (pb.authStore.isValid) {
try {
const authData = await pb.collection('users').authRefresh();
displayUserInfo(authData);
// If we came from a reauth flow and now have a token, go back automatically
const hasToken = localStorage.getItem(GRAPH_TOKEN_KEY);
if (reauth && hasToken) {
window.location.href = 'index.html';
}
} catch (err) {
pb.authStore.clear();
logout();