2
0

feat(integration): ️ Improve feedback on GSheets errors

This commit is contained in:
Baptiste Arnaud
2022-03-04 14:40:13 +01:00
parent 9b8f153579
commit d13ca0fa9a
6 changed files with 45 additions and 16 deletions

View File

@ -13,10 +13,11 @@ export const oauth2Client = new OAuth2Client(
export const getAuthenticatedGoogleClient = async (
userId: string,
credentialsId: string
): Promise<OAuth2Client> => {
): Promise<OAuth2Client | undefined> => {
const credentials = (await prisma.credentials.findFirst({
where: { id: credentialsId, ownerId: userId },
})) as CredentialsFromDb
})) as CredentialsFromDb | undefined
if (!credentials) return
const data = decrypt(
credentials.data,
credentials.iv