-
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.
Merge pull request #45 from wafflestudio/feat/socialLogin
jwtauthenticationfilter 예전버전으로 바꿈
- Loading branch information
Showing
3 changed files
with
73 additions
and
6 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
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/com/toyProject7/karrot/user/persistence/UserPrincipal.kt
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,43 @@ | ||
package com.toyProject7.karrot.user.persistence | ||
|
||
import org.springframework.security.core.GrantedAuthority | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority | ||
import org.springframework.security.core.userdetails.UserDetails | ||
|
||
data class UserPrincipal( | ||
val id: String, | ||
private val email: String, | ||
private val nickname: String, | ||
private val password: String?, | ||
private val authorities: Collection<GrantedAuthority>, | ||
) : UserDetails { | ||
companion object { | ||
fun create(user: UserEntity): UserPrincipal { | ||
val authorities = listOf(SimpleGrantedAuthority("ROLE_USER")) | ||
|
||
return UserPrincipal( | ||
id = user.id!!, | ||
email = user.email, | ||
nickname = user.nickname, | ||
password = null, | ||
authorities = authorities, | ||
) | ||
} | ||
} | ||
|
||
override fun getAuthorities(): Collection<GrantedAuthority> = authorities | ||
|
||
override fun getPassword(): String? = password | ||
|
||
fun getNickname(): String = nickname | ||
|
||
override fun getUsername(): String = email | ||
|
||
override fun isAccountNonExpired(): Boolean = true | ||
|
||
override fun isAccountNonLocked(): Boolean = true | ||
|
||
override fun isCredentialsNonExpired(): Boolean = true | ||
|
||
override fun isEnabled(): Boolean = 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