fix(editor): 🔒️ Enforce credentials security
This commit is contained in:
@ -14,10 +14,10 @@ export const getAuthenticatedGoogleClient = async (
|
|||||||
userId: string,
|
userId: string,
|
||||||
credentialsId: string
|
credentialsId: string
|
||||||
): Promise<OAuth2Client | undefined> => {
|
): Promise<OAuth2Client | undefined> => {
|
||||||
const credentials = (await prisma.credentials.findFirst({
|
const credentials = (await prisma.credentials.findUnique({
|
||||||
where: { id: credentialsId, ownerId: userId },
|
where: { id: credentialsId },
|
||||||
})) as CredentialsFromDb | undefined
|
})) as CredentialsFromDb | undefined
|
||||||
if (!credentials) return
|
if (!credentials || credentials.ownerId !== userId) return
|
||||||
const data = decrypt(
|
const data = decrypt(
|
||||||
credentials.data,
|
credentials.data,
|
||||||
credentials.iv
|
credentials.iv
|
||||||
|
@ -18,8 +18,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||||||
return res.status(404).send("Couldn't find credentials in database")
|
return res.status(404).send("Couldn't find credentials in database")
|
||||||
const response = await drive({
|
const response = await drive({
|
||||||
version: 'v3',
|
version: 'v3',
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore
|
|
||||||
auth: auth,
|
auth: auth,
|
||||||
}).files.list({
|
}).files.list({
|
||||||
q: "mimeType='application/vnd.google-apps.spreadsheet'",
|
q: "mimeType='application/vnd.google-apps.spreadsheet'",
|
||||||
|
Reference in New Issue
Block a user