Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit b8c9bdf

Browse files
committed
feat: Validate password type during user registration
1 parent 5bb924a commit b8c9bdf

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

dist/controllers/UserController.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ let Users = class Users {
179179
}
180180
let hashedPassword = null;
181181
if (req.body.password) {
182+
if (typeof req.body.password !== "string") {
183+
await this.createLog(req, "register", "users", 400);
184+
return this.sendError(res, 400, "Invalid password");
185+
}
182186
hashedPassword = await bcryptjs_1.default.hash(req.body.password, 10);
183187
}
184188
try {

src/controllers/UserController.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ export class Users {
182182
}
183183
let hashedPassword = null;
184184
if (req.body.password) {
185+
if(typeof req.body.password !== "string") {
186+
await this.createLog(req, "register", "users", 400);
187+
return this.sendError(res, 400, "Invalid password");
188+
}
185189
hashedPassword = await bcrypt.hash(req.body.password, 10);
186190
}
187191
try {

0 commit comments

Comments
 (0)