You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: validate types for login email and password (500 on non-string or missing body) #235
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:
{"email":{},"password":"x"}: gets past the check, then Prisma throws a validation error in findUnique.
{"email":"real@user.com","password":123}: bcrypt.compare throws on a non string.
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