https://kotlinlang.org logo
#spring
Title
c

Czar

11/06/2017, 9:16 PM
That's a different problem I've solved before I bumped into the one I asked about 🙂
In the end I ended up with this:
Copy code
@Bean
	fun userDetailsService() = UserDetailsService { username: String ->
		userAccountRepository.findByUsernameLowerCased(username.toLowerCase())?.toUserDetails()
				?: throw UsernameNotFoundException("Could not find user with username $username")
	}
private fun UserAccount.toUserDetails(): UserDetails = User(
		username, password, enabled,
		true, true, true,
		setOf(SimpleGrantedAuthority("USER")))
2 Views