-
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.
- UserDetails 인터페이스를 구현 - MemberRole Enum 클래스 추가
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.j9.bestmoments.member; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import java.util.Collection; | ||
import java.util.UUID; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.GenericGenerator; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
@Entity | ||
@Getter | ||
@EqualsAndHashCode | ||
@NoArgsConstructor | ||
public class Member implements UserDetails { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
@GenericGenerator(name="uuid2", strategy = "uuid2") | ||
@Column(columnDefinition = "BINARY(16)") | ||
private UUID id; | ||
private String oauthProvider; | ||
private String oauthId; | ||
private String name; | ||
private String email; | ||
private MemberRole role; | ||
private String profileImageUrl; | ||
|
||
@Builder | ||
private Member(String name, String email, MemberRole role, String profileImageUrl, String oauthProvider, String oauthId) { | ||
this.name = name; | ||
this.email = email; | ||
this.role = role; | ||
this.profileImageUrl = profileImageUrl; | ||
this.oauthProvider = oauthProvider; | ||
this.oauthId = oauthId; | ||
} | ||
|
||
@Override | ||
public Collection<? extends GrantedAuthority> getAuthorities() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getPassword() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getUsername() { | ||
return id.toString(); | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isAccountNonLocked() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isCredentialsNonExpired() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
} |
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,16 @@ | ||
package com.j9.bestmoments.member; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public enum MemberRole { | ||
|
||
USER("user"), | ||
ADMIN("admin"), | ||
; | ||
|
||
private final String key; | ||
|
||
} |