Add param validation so we dont get undefined values passed to GQL

This commit is contained in:
Jackson Harper 2022-07-21 17:43:15 -07:00
parent 291bb59248
commit c113c94567

View file

@ -356,6 +356,11 @@ export function authRouter() {
cors<express.Request>(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<express.Request>(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 {