-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from 9oormthon-univ/dev
Fix Token
- Loading branch information
Showing
4 changed files
with
50 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/univ/yesummit/global/auth/service/AuthService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package univ.yesummit.global.auth.service; | ||
|
||
import java.util.Map; | ||
|
||
public interface AuthService { | ||
|
||
Map<String, Object> generateTokens(Long userId) throws Exception; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/univ/yesummit/global/auth/service/impl/AuthServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package univ.yesummit.global.auth.service.impl; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import univ.yesummit.domain.member.service.MemberService; | ||
import univ.yesummit.global.auth.service.AuthService; | ||
import univ.yesummit.global.auth.util.JwtUtils; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AuthServiceImpl implements AuthService { | ||
|
||
|
||
private final JwtUtils jwtUtils; | ||
private final MemberService memberService; | ||
|
||
public Map<String, Object> generateTokens(Long userId) { | ||
// JWT 토큰 생성 | ||
String accessToken = jwtUtils.createAccessToken(userId); | ||
String refreshToken = jwtUtils.createRefreshToken(userId); | ||
|
||
// 첫 로그인 여부 확인 | ||
boolean isFirstLogin = memberService.isFirstLogin(userId); | ||
|
||
// 결과 데이터 구성 | ||
Map<String, Object> tokens = new HashMap<>(); | ||
tokens.put("accessToken", accessToken); | ||
tokens.put("refreshToken", refreshToken); | ||
tokens.put("firstLogin", isFirstLogin); | ||
|
||
return tokens; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters