Skip to content

Commit

Permalink
Merge pull request #41 from 9oormthon-univ/dev
Browse files Browse the repository at this point in the history
[#2]✨Feat: 토큰 발급 시 리프레시 토큰 저장
  • Loading branch information
sumin220 authored Nov 23, 2024
2 parents 4faaf0a + 193af1b commit 08729fe
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 08729fe

Please sign in to comment.