Skip to content

Commit

Permalink
feat: add userId in CustomUserDetails domain
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyLightQP committed Jan 1, 2025
1 parent df13ce4 commit 5abd82c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package me.daegyeo.maru.auth.application.domain
import org.springframework.security.core.GrantedAuthority
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.UserDetails
import java.util.UUID

class CustomUserDetails(private val email: String) : UserDetails {
class CustomUserDetails(private val email: String, val userId: UUID) : UserDetails {
override fun getAuthorities(): Collection<GrantedAuthority> {
return listOf("ROLE_USER").map { SimpleGrantedAuthority(it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CustomUserDetailsService(private val getUserUseCase: GetUserUseCase) : Cus
override fun loadUserByUsername(username: String?): UserDetails {
try {
val user = getUserUseCase.getUserByEmail(username!!)
return CustomUserDetails(user.email)
return CustomUserDetails(user.email, user.userId)
} catch (e: ServiceException) {
throw UsernameNotFoundException("User not found")
} catch (e: Exception) {
Expand Down

0 comments on commit 5abd82c

Please sign in to comment.