fixed request for reauth on clicking show folder
This commit is contained in:
@@ -58,9 +58,35 @@
|
||||
errorEl.classList.add('hidden');
|
||||
|
||||
try {
|
||||
// Step 1: Authenticate with PocketBase via Microsoft OAuth
|
||||
const authData = await pb.collection('users').authWithOAuth2({
|
||||
provider: 'microsoft',
|
||||
});
|
||||
|
||||
// Step 2: Try to get Graph token from PB response
|
||||
let graphToken = (
|
||||
authData?.meta?.graphAccessToken ||
|
||||
authData?.meta?.graph_token ||
|
||||
authData?.meta?.graphToken ||
|
||||
authData?.meta?.accessToken ||
|
||||
authData?.meta?.access_token ||
|
||||
authData?.meta?.token ||
|
||||
''
|
||||
);
|
||||
|
||||
// Step 3: If no Graph token from PB, use the OAuth token as the Graph token
|
||||
// (PB's Microsoft OAuth should return a token that works with Graph API)
|
||||
if (!graphToken && authData?.meta?.rawUser) {
|
||||
// The OAuth token from Microsoft should work for Graph API calls
|
||||
graphToken = authData?.token || authData?.meta?.accessToken || '';
|
||||
}
|
||||
|
||||
if (graphToken) {
|
||||
const expiresAt = authData?.meta?.graphTokenExpiresAt || new Date(Date.now() + 3600000).toISOString();
|
||||
await tokenManager.setToken(graphToken, expiresAt);
|
||||
console.log('[Login] Graph token stored successfully');
|
||||
}
|
||||
|
||||
displayUserInfo(authData);
|
||||
} catch (error) {
|
||||
console.error('Login failed:', error);
|
||||
|
||||
Reference in New Issue
Block a user