Skip to content

fix: validate types for login email and password (500 on non-string or missing body) #235

Open

Description

@Anshuu2004

Summary

userLoginController (apps/http-server/src/controllers/authController.ts) is the one auth input that is still only checked for being truthy. Register has parseRegisterInput, and join and create quiz got the same treatment in #231, but login still does const { email, password } = req.body and if (!email || !password).

What happens

From reading the code, POST /api/v1/auth/login should give a generic 500 in these cases:

I didn't run these against a database, the join versions behaved this way when I tested #234.

Expected behaviour

400 with a clear message for wrong types.

Proposed fix

A small parseLoginInput next to registerInput.ts, returned through the existing errorResponse(res, 400, ...), with tests for the object, array, number and no body cases.

Happy to send a PR for this, and #234 is merged so I don't have anything else open here. Labels and level are your call.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions