From 852654ebb8ba61ecd83fb990f146b904cf8ada61 Mon Sep 17 00:00:00 2001 From: khl6235 Date: Wed, 13 Apr 2022 17:24:10 +0900 Subject: [PATCH] FIX: duplicateCheck nickname validation #2 --- vinyla/controllers/user.js | 4 ++++ vinyla/modules/responseMessage.js | 1 + 2 files changed, 5 insertions(+) diff --git a/vinyla/controllers/user.js b/vinyla/controllers/user.js index 548cf15..b2052e8 100644 --- a/vinyla/controllers/user.js +++ b/vinyla/controllers/user.js @@ -42,6 +42,10 @@ module.exports = { if(!nickname){ return await res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, resMessage.NULL_VALUE)); } + const regex = /^[ㄱ-ㅎ|가-힣|a-z|A-Z|0-9|]+$/; + if(nickname.length < 2 || nickname.length > 20 || !regex.test(nickname)){ + return await res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, resMessage.INVALID_NICKNAME)); + } const isDuplicate = await UserModel.duplicateCheck(nickname); if(!isDuplicate){ return await res.status(statusCode.BAD_REQUEST).send(util.fail(statusCode.BAD_REQUEST, resMessage.ALREADY_NICKNAME)); diff --git a/vinyla/modules/responseMessage.js b/vinyla/modules/responseMessage.js index 6b5e603..f813068 100644 --- a/vinyla/modules/responseMessage.js +++ b/vinyla/modules/responseMessage.js @@ -7,6 +7,7 @@ module.exports = { DELETE_USER: "회원 탈퇴 성공", ALREADY_NICKNAME: "사용 중인 닉네임입니다.", + INVALID_NICKNAME: "올바르지 않은 형식입니다.", NO_DUPLICATE: "사용 가능한 닉네임입니다.", LOGIN_SUCCESS: "로그인 성공",