From c113c94567b9779ea416ea95ec886f58c7201b46 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 21 Jul 2022 17:43:15 -0700 Subject: [PATCH] Add param validation so we dont get undefined values passed to GQL --- packages/api/src/routers/auth/auth_router.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/api/src/routers/auth/auth_router.ts b/packages/api/src/routers/auth/auth_router.ts index b3d8853b6..d9289111e 100644 --- a/packages/api/src/routers/auth/auth_router.ts +++ b/packages/api/src/routers/auth/auth_router.ts @@ -356,6 +356,11 @@ export function authRouter() { cors(corsConfig), async (req: express.Request, res: express.Response) => { const { email, password } = req.body + if (!email || !password) { + res.redirect(`${env.client.url}/email-login?errorCodes=AUTH_FAILED`) + return + } + const query = ` mutation login{ login(input: { @@ -418,6 +423,11 @@ export function authRouter() { cors(corsConfig), async (req: express.Request, res: express.Response) => { const { email, password, name, username, bio } = req.body + if (!email || !password || !name || !username) { + res.redirect(`${env.client.url}/email-signup?errorCodes=BAD_DATA`) + return + } + const query = ` mutation signup { signup(input: { @@ -425,7 +435,7 @@ export function authRouter() { password: "${password}", name: "${name}", username: "${username}", - bio: "${bio}" + bio: "${bio ?? ''}" }) { __typename ... on SignupSuccess {