Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

사용자 회원가입시 한국어가 입력 가능하도록 패턴 수정 #132

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public MemberResponseDto signup(MemberRequestDto request, MemberRole role) {
if(memberRepository.findByEmail(request.getEmail()).isPresent())
throw new GlobalException(MemberErrorCode.DUPLICATED_EMAIL);

if(!request.getMemberName().matches("^[a-zA-Z0-9]{4,20}$"))
if(!request.getMemberName().matches("^[a-zA-Z0-9가-힣]{4,20}$"))
throw new GlobalException(MemberErrorCode.INVALID_MEMBER_NAME);

//MemberMapper를 이용한 Entity 생성
Expand Down Expand Up @@ -96,14 +96,7 @@ public void login(MemberRequestDto request, HttpServletResponse response) {

Member member = ((MemberDetailsImpl) authentication.getPrincipal()).getMember();

String accessToken = jwtUtil.generateAccessToken(member.getEmail(), member.getRole());
String refreshToken = jwtUtil.generateRefreshToken();

//ResponseHeader에 토큰 추가
jwtUtil.setJwtHeader(response, accessToken, refreshToken);

//Redis에 refreshToken 저장
redisUtil.saveRefreshToken(refreshToken, member.getEmail());
setTokenHeaderAndRedis(response, member);

} catch(BadCredentialsException e) {
throw new GlobalException(MemberErrorCode.INVALID_AUTH);
Expand Down Expand Up @@ -236,8 +229,10 @@ private void setTokenHeaderAndRedis(HttpServletResponse response, Member socialM
String aToken = jwtUtil.generateAccessToken(socialMember.getEmail(), socialMember.getRole());
String rToken = jwtUtil.generateRefreshToken();

//ResponseHeader에 토큰 추가
jwtUtil.setJwtHeader(response, aToken, rToken);

//Redis에 refreshToken 저장
redisUtil.saveRefreshToken(rToken, socialMember.getEmail());
}
}
Loading