Skip to content

Commit

Permalink
feat : 인가시 저장되는 CustomOAuth2User 구현 (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-ho committed Mar 8, 2024
1 parent 23b31a5 commit 8a9a2b0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
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;
}
}
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);
}
}

0 comments on commit 8a9a2b0

Please sign in to comment.