2
0

fix(editor): 🔒️ Enforce credentials security

This commit is contained in:
Baptiste Arnaud
2022-04-14 15:45:52 -07:00
parent 18319c88c8
commit ed680969f9
2 changed files with 3 additions and 5 deletions

View File

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