many edits
This commit is contained in:
+12
-1
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user