fix: validate types for login email and password (500 on non-string or missing body)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- express, postgresql, typescript
- 领域
- api, authentication, backend
调研方向
阅读 apps/http-server/src/controllers/authController.ts 和 registerInput.ts 中现有的 parseRegisterInput 实现,了解项目的输入解析模式。按说明为对象、数组、数字和缺少 body 的情况添加登录输入测试。无效输入返回明确的 400 响应,而不是导致 500,才算完成。
由索引模型根据 Issue 内容生成。
描述
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:
- No JSON body: the destructure throws, same as the no body case that #234 fixed for join.
{"email":{},"password":"x"}: gets past the check, then Prisma throws a validation error infindUnique.{"email":"[email protected]","password":123}:bcrypt.comparethrows 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.
- 主要语言
- TypeScript
- 星标
- 21
- 派生
- 7
- 平均合并
- 8 小时 12 分钟
- 30 天内合并 PR
- 36
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TheCodeHeist-Coder/Rexial 的其他 Issue
-
bug good first issue help wanted UI & UX
难度 1/5 1 小时以内 新手友好度 95/100
TheCodeHeist-Coder/Rexial#178 · 2 条评论 ·
维护者通常 1 天内回复
-
bug enhancement good first issue help wanted UI & UX
难度 2/5 1-3 小时 新手友好度 78/100
TheCodeHeist-Coder/Rexial#162 ·
维护者通常 1 天内回复
-
Critical security: a couple of access control problems in the API and ws-server (details to be shared privately)可能已有人在做 @Anshuu2004 于 11 天前认领。 未关闭level3 nsoc26
难度 4/5 3-5 天 新手友好度 35/100
TheCodeHeist-Coder/Rexial#215 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement help wanted UI & UX
难度 4/5 3-5 天 新手友好度 54/100
TheCodeHeist-Coder/Rexial#201 · 1 条评论 ·
维护者通常 1 天内回复
-
A host cannot see who won a quiz they already hosted可能已有人在做 @Harshit214713 于 11 天前认领。 未关闭enhancement good first issue help wanted level2 nsoc26 UI & UX
难度 4/5 3-5 天 新手友好度 58/100
TheCodeHeist-Coder/Rexial#200 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 TheCodeHeist-Coder/Rexial 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
readest/readest#7413 · 1 条评论 ·
维护者通常 1 天内回复
-
content triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
eliasstravik/herdr-projects#788 ·
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复