mirror of
https://github.com/urosran/cally.git
synced 2025-07-15 01:35:22 +00:00
- Implemented connecting multiple accounts for microsoft
This commit is contained in:
@ -204,11 +204,17 @@ exports.refreshTokens = functions.pubsub.schedule('every 12 hours').onRun(async
|
||||
}
|
||||
}
|
||||
|
||||
if (profileData.microsoftToken) {
|
||||
if (profileData.microsoftAccounts) {
|
||||
try {
|
||||
const refreshedMicrosoftToken = await refreshMicrosoftToken(profileData.microsoftToken);
|
||||
await profileDoc.ref.update({microsoftToken: refreshedMicrosoftToken});
|
||||
console.log(`Microsoft token updated for user ${profileDoc.id}`);
|
||||
for (const microsoftEmail of Object.keys(profileData?.microsoftAccounts)) {
|
||||
const microsoftToken = profileData?.microsoftAccounts?.[microsoftEmail];
|
||||
if (microsoftToken) {
|
||||
const refreshedMicrosoftToken = await refreshMicrosoftToken(microsoftToken);
|
||||
const updatedMicrosoftAccounts = {...profileData.microsoftAccounts, [microsoftEmail]: refreshedMicrosoftToken};
|
||||
await profileDoc.ref.update({microsoftAccounts: updatedMicrosoftAccounts});
|
||||
console.log(`Microsoft token updated for user ${profileDoc.id}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error refreshing Microsoft token for user ${profileDoc.id}:`, error.message);
|
||||
}
|
||||
|
Reference in New Issue
Block a user