diff --git a/src/main/kotlin/com/wbrawner/budgetserver/config/JdbcUserDetailsService.kt b/src/main/kotlin/com/wbrawner/budgetserver/config/JdbcUserDetailsService.kt index a2c45f8..b268070 100644 --- a/src/main/kotlin/com/wbrawner/budgetserver/config/JdbcUserDetailsService.kt +++ b/src/main/kotlin/com/wbrawner/budgetserver/config/JdbcUserDetailsService.kt @@ -13,7 +13,12 @@ constructor(private val userRepository: UserRepository) : UserDetailsService { @Throws(UsernameNotFoundException::class) override fun loadUserByUsername(username: String): UserDetails { - return userRepository.findByName(username).orElse(null) - ?: throw UsernameNotFoundException("Unable to find user with username $username") + userRepository.findByName(username).orElse(null)?.let { + return it + } + userRepository.findByEmail(username).orElse(null)?.let { + return it + } + throw UsernameNotFoundException("Unable to find user with username $username") } } \ No newline at end of file