Skip to content

Commit

Permalink
Merge pull request #132 from SportsEcho/feature/user
Browse files Browse the repository at this point in the history
�사용자 회원가입시 한국어가 입력 가능하도록 패턴 수정
  • Loading branch information
zzzzseong authored Jan 26, 2024
2 parents c611e37 + d38b5cd commit 7272b11
Showing 1 changed file with 4 additions and 9 deletions.
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());
}
}

0 comments on commit 7272b11

Please sign in to comment.