Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Sep 3, 2024
1 parent 04183e8 commit 3239e26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ class UserFacade(
) {

fun currentUser(): User? {
val authentication = SecurityContextHolder.getContext().authentication
val accountId = authentication?.name
val accountId = SecurityContextHolder.getContext().authentication.name
return accountId?.let { getUserByAccountId(it) }
}

fun getUserByAccountId(accountId: String): User =
fun getUserByAccountId(accountId: String) =
userRepository.findByAccountId(accountId) ?: throw UserNotFoundException
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.meogo.domain.user.repository

import org.meogo.domain.user.domain.User
import org.springframework.data.repository.Repository
import org.springframework.data.jpa.repository.JpaRepository
import java.util.UUID

interface UserRepository : Repository<User, UUID> {
interface UserRepository : JpaRepository<User, UUID> {
fun save(entity: User): User

fun findByAccountId(accountId: String): User?
Expand Down

0 comments on commit 3239e26

Please sign in to comment.