Skip to content

Commit

Permalink
fix: πŸ”’οΈ Better guard spreadsheets GET
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Apr 9, 2022
1 parent 378fe0f commit 97ba29f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { drive } from '@googleapis/drive'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { methodNotAllowed, notAuthenticated } from 'utils'
import { badRequest, methodNotAllowed, notAuthenticated } from 'utils'
import { setUser, withSentry } from '@sentry/nextjs'
import { getAuthenticatedUser } from 'services/api/utils'

Expand All @@ -11,7 +11,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {

setUser({ email: user.email ?? undefined, id: user.id })
if (req.method === 'GET') {
const credentialsId = req.query.credentialsId.toString()
const credentialsId = req.query.credentialsId as string | undefined
if (!credentialsId) return badRequest(res)
const auth = await getAuthenticatedGoogleClient(user.id, credentialsId)
if (!auth)
return res.status(404).send("Couldn't find credentials in database")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { GoogleSpreadsheet } from 'google-spreadsheet'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { isDefined, methodNotAllowed, notAuthenticated } from 'utils'
import {
badRequest,
isDefined,
methodNotAllowed,
notAuthenticated,
} from 'utils'
import { withSentry, setUser } from '@sentry/nextjs'
import { getAuthenticatedUser } from 'services/api/utils'

Expand All @@ -11,7 +16,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {

setUser({ email: user.email ?? undefined, id: user.id })
if (req.method === 'GET') {
const credentialsId = req.query.credentialsId.toString()
const credentialsId = req.query.credentialsId as string | undefined
if (!credentialsId) return badRequest(res)

const spreadsheetId = req.query.id.toString()
const doc = new GoogleSpreadsheet(spreadsheetId)
Expand Down

4 comments on commit 97ba29f

@vercel
Copy link

@vercel vercel bot commented on 97ba29f Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landing-page-v2 – ./apps/landing-page

get-typebot.com
www.get-typebot.com
www.typebot.io
landing-page-v2-typebot-io.vercel.app
landing-page-v2-git-main-typebot-io.vercel.app
typebot.io

@vercel
Copy link

@vercel vercel bot commented on 97ba29f Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 97ba29f Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 97ba29f Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.