From 2aeb07ecfc341be2331d946c15be8b2221de0eaa Mon Sep 17 00:00:00 2001 From: zzzzseong Date: Tue, 23 Jan 2024 21:04:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor(Member):=20MemberService=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EB=B0=9C=ED=96=89=20=EB=B0=8F=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=95=A8=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/service/MemberServiceImplV2.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java index a7b6c589..400a4185 100644 --- a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java +++ b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java @@ -106,14 +106,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); @@ -246,8 +239,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()); } } From d38b5cdd757d0006fe253ca8faeef691c5f1a228 Mon Sep 17 00:00:00 2001 From: zzzzseong Date: Fri, 26 Jan 2024 18:00:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix(Member):=20=EC=82=AC=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=EC=8B=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=ED=95=9C=EA=B5=AD=EC=96=B4=20=ED=8C=A8=ED=84=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sportsecho/member/service/MemberServiceImplV2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java index 94e1ee85..f522a263 100644 --- a/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java +++ b/src/main/java/com/sportsecho/member/service/MemberServiceImplV2.java @@ -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 생성