-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : 인가시 저장되는 CustomOAuth2User 구현 (#112)
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/gdsc/binaryho/imhere/security/SignUpProcessRedirectionPath.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,26 @@ | ||
package gdsc.binaryho.imhere.security; | ||
|
||
import gdsc.binaryho.imhere.core.member.Member; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum SignUpProcessRedirectionPath { | ||
|
||
BEFORE_MEMBER_INFO_INPUT("/signup"), | ||
SIGN_UP_DONE("/main"), | ||
; | ||
|
||
private final String redirectUrlPath; | ||
|
||
public static SignUpProcessRedirectionPath of(Member member) { | ||
if (member.getName() == null) { | ||
return BEFORE_MEMBER_INFO_INPUT; | ||
} | ||
|
||
return SIGN_UP_DONE; | ||
} | ||
|
||
SignUpProcessRedirectionPath(String redirectUrlPath) { | ||
this.redirectUrlPath = redirectUrlPath; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/gdsc/binaryho/imhere/security/oauth/CustomOAuth2User.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,22 @@ | ||
package gdsc.binaryho.imhere.security.oauth; | ||
|
||
import gdsc.binaryho.imhere.core.member.Member; | ||
import gdsc.binaryho.imhere.core.member.Role; | ||
import gdsc.binaryho.imhere.security.SignUpProcessRedirectionPath; | ||
import lombok.Getter; | ||
import org.springframework.security.oauth2.core.user.DefaultOAuth2User; | ||
|
||
@Getter | ||
public class CustomOAuth2User extends DefaultOAuth2User { | ||
|
||
private final Long memberId; | ||
private final Role role; | ||
private final SignUpProcessRedirectionPath signUpProcessRedirectionPath; | ||
|
||
public CustomOAuth2User(GitHubUser gitHubUser, Member member) { | ||
super(gitHubUser.getAuthorities(), gitHubUser.getAttributes(), GitHubUser.GITHUB_NAME_ATTRIBUTE_KEY); | ||
this.memberId = member.getId(); | ||
this.role = member.getRole(); | ||
this.signUpProcessRedirectionPath = SignUpProcessRedirectionPath.of(member); | ||
} | ||
} |