Skip to content

Commit 10dfcc8

Browse files
committed
feat: enhance input validation for username and password during signup
1 parent 5ccef85 commit 10dfcc8

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

API/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ app.post('/api/signup', async (req, res) => {
207207
}
208208

209209
// Check if the username contains at least 5 characters
210-
if (username.length < 5) {
210+
if (String(username).length < 5) {
211211
const data = {
212212
"STATUS": "ERROR",
213213
"MESSAGE": "BAD REQUEST - THE USERNAME HAS LESS THAN 5 CHARACTERS",
@@ -221,7 +221,7 @@ app.post('/api/signup', async (req, res) => {
221221
}
222222

223223
// Check if the username is more than 20 characters
224-
if (username.length > 20) {
224+
if (String(username).length > 20) {
225225
const data = {
226226
"STATUS": "ERROR",
227227
"MESSAGE": "BAD REQUEST - THE USERNAME HAS MORE THAN 20 CHARACTERS",
@@ -235,7 +235,7 @@ app.post('/api/signup', async (req, res) => {
235235
}
236236

237237
// Check if the password contains at least 6 characters
238-
if (password.length < 6) {
238+
if (String(password).length < 6) {
239239
const data = {
240240
"STATUS": "ERROR",
241241
"MESSAGE": "BAD REQUEST - THE PASSWORD HAS LESS THAN 6 CHARACTERS",
@@ -249,7 +249,7 @@ app.post('/api/signup', async (req, res) => {
249249
}
250250

251251
// Check if the password is more than 80 characters
252-
if (password.length > 80) {
252+
if (String(password).length > 80) {
253253
const data = {
254254
"STATUS": "ERROR",
255255
"MESSAGE": "BAD REQUEST - THE PASSWORD HAS MORE THAN 80 CHARACTERS",

0 commit comments

Comments
 (0)