Allow login with username or email
This commit is contained in:
parent
6191ed9fe4
commit
08ecc1ce26
1 changed files with 7 additions and 2 deletions
|
@ -13,7 +13,12 @@ constructor(private val userRepository: UserRepository) : UserDetailsService {
|
||||||
|
|
||||||
@Throws(UsernameNotFoundException::class)
|
@Throws(UsernameNotFoundException::class)
|
||||||
override fun loadUserByUsername(username: String): UserDetails {
|
override fun loadUserByUsername(username: String): UserDetails {
|
||||||
return userRepository.findByName(username).orElse(null)
|
userRepository.findByName(username).orElse(null)?.let {
|
||||||
?: throw UsernameNotFoundException("Unable to find user with username $username")
|
return it
|
||||||
|
}
|
||||||
|
userRepository.findByEmail(username).orElse(null)?.let {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
throw UsernameNotFoundException("Unable to find user with username $username")
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue