feat(be): modify signup logic#3598
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the user sign-up process by adding nickname and jobType fields to the SignUpDto and implementing validation logic based on the user's job type. Specifically, it removes the @skku.edu email restriction during the initial pin generation and instead enforces it during registration for users who identify as Sungkyunkwan University (SKKU) students, alongside requiring their student ID and major. Other college students are required to provide their college name. Feedback on these changes highlights potential issues with the validation logic: the check for SKKU affiliation can be easily bypassed with variations like '성균관대' or 'SKKU', and the email domain check is case-sensitive and should convert the email to lowercase first to prevent false negatives.
| if ( | ||
| signUpDto.jobType === JobType.CollegeStudent && | ||
| signUpDto.college?.includes('성균관대학교') | ||
| ) { |
There was a problem hiding this comment.
성균관대학교 학생인 경우 학번, 학과 및 @skku.edu 이메일 인증을 강제하고 있으나, signUpDto.college?.includes('성균관대학교') 조건은 '성균관대' 또는 'SKKU'와 같은 입력에 대해 우회될 수 있습니다. 대학 이름 입력값을 정규화하거나 대표적인 약칭들을 함께 검사하는 로직을 추가하는 것이 안전합니다.
if (
signUpDto.jobType === JobType.CollegeStudent &&
signUpDto.college &&
/성균관대|skku/i.test(signUpDto.college)
) {| if (!email.endsWith('@skku.edu')) { | ||
| throw new UnprocessableDataException('SKKU not using @skku.edu email') | ||
| } |
There was a problem hiding this comment.
email.endsWith('@skku.edu') 검사는 대소문자를 구분합니다. 사용자가 이메일 주소에 대문자를 포함하여 인증받은 경우(예: user@SKKU.EDU), 이 조건문에서 검증이 실패할 수 있습니다. 안전하게 비교하기 위해 이메일을 소문자로 변환한 후 검사하는 것이 좋습니다.
| if (!email.endsWith('@skku.edu')) { | |
| throw new UnprocessableDataException('SKKU not using @skku.edu email') | |
| } | |
| if (!email.toLowerCase().endsWith('@skku.edu')) { | |
| throw new UnprocessableDataException('SKKU not using @skku.edu email') | |
| } |
Description
Additional context
화이트리스트 제거에 따른 회원가입 로직 수정
SignUpDto에nickname,jobType필드 추가UpdateUserDto에nickname필드 추가@skku.edu도메인 제한 제거jobType에 따른 회원가입 분기 처리@skku.edu이메일 검증createUser에nickname,jobType저장 추가getUserProfile에nickname,jobType,profileImageUrl응답 추가UpdateUserDto에nickname필드 추가updateUser에nickname수정 기능 추가Before submitting the PR, please make sure you do the following
fixes #123).