Skip to content

Commit

Permalink
[#2]✨Feat: 토큰 발급 시 리프레시 토큰 저장
Browse files Browse the repository at this point in the history
  • Loading branch information
sumin220 committed Nov 23, 2024
1 parent 6548e88 commit 193af1b
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import univ.yesummit.domain.member.entity.Member;
import univ.yesummit.domain.member.exception.MemberException;
import univ.yesummit.domain.member.repository.MemberRepository;
import univ.yesummit.domain.member.service.MemberService;
import univ.yesummit.global.auth.service.AuthService;
import univ.yesummit.global.auth.util.JwtUtils;
import univ.yesummit.global.exception.ErrorCode;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -16,12 +20,20 @@ public class AuthServiceImpl implements AuthService {

private final JwtUtils jwtUtils;
private final MemberService memberService;
private final MemberRepository memberRepository;

public Map<String, Object> generateTokens(Long userId) {

Member member = memberRepository.findById(userId)
.orElseThrow(() -> new MemberException(ErrorCode.NOT_FOUND_MEMBER));


// JWT 토큰 생성
String accessToken = jwtUtils.createAccessToken(userId);
String refreshToken = jwtUtils.createRefreshToken(userId);

member.updateRefreshToken(refreshToken);

// 첫 로그인 여부 확인
boolean isFirstLogin = memberService.isFirstLogin(userId);

Expand Down

0 comments on commit 193af1b

Please sign in to comment.