modified backend controllers to support new auth providers

This commit is contained in:
Sheen Capadngan
2023-08-06 19:45:27 +08:00
parent 5604232aea
commit 04fdccc45d
5 changed files with 25 additions and 6 deletions
+5 -2
View File
@@ -390,10 +390,13 @@ export const validateProviderAuthToken = async ({
jwt.verify(providerAuthToken, await getJwtProviderAuthSecret())
);
const doesProviderMatch = (user.authProvider && user.authProvider === decodedToken.authProvider)
|| (user.authProviders && user.authProviders.includes(decodedToken.authProvider));
if (
decodedToken.authProvider !== user.authProvider ||
!doesProviderMatch ||
decodedToken.email !== email
) {
throw new Error("Invalid authentication credentials.")
}
}
}