mirror of
https://github.com/gotson/komga.git
synced 2026-05-05 11:01:57 +02:00
make user login case insensitive
This commit is contained in:
parent
e5e7526365
commit
cb2778278a
2 changed files with 5 additions and 5 deletions
|
|
@ -6,6 +6,6 @@ import org.springframework.stereotype.Repository
|
|||
|
||||
@Repository
|
||||
interface KomgaUserRepository : CrudRepository<KomgaUser, Long> {
|
||||
fun existsByEmail(email: String): Boolean
|
||||
fun findByEmail(email: String): KomgaUser?
|
||||
fun existsByEmailIgnoreCase(email: String): Boolean
|
||||
fun findByEmailIgnoreCase(email: String): KomgaUser?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ class KomgaUserDetailsLifecycle(
|
|||
) : UserDetailsService {
|
||||
|
||||
override fun loadUserByUsername(username: String): UserDetails =
|
||||
userRepository.findByEmail(username)?.let {
|
||||
userRepository.findByEmailIgnoreCase(username)?.let {
|
||||
KomgaPrincipal(it)
|
||||
} ?: throw UsernameNotFoundException(username)
|
||||
|
||||
@Transactional
|
||||
fun updatePassword(user: UserDetails, newPassword: String, expireSessions: Boolean): UserDetails {
|
||||
userRepository.findByEmail(user.username)?.let { komgaUser ->
|
||||
userRepository.findByEmailIgnoreCase(user.username)?.let { komgaUser ->
|
||||
logger.info { "Changing password for user ${user.username}" }
|
||||
komgaUser.password = passwordEncoder.encode(newPassword)
|
||||
userRepository.save(komgaUser)
|
||||
|
|
@ -46,7 +46,7 @@ class KomgaUserDetailsLifecycle(
|
|||
@Transactional
|
||||
@Throws(UserEmailAlreadyExistsException::class)
|
||||
fun createUser(user: UserDetails): UserDetails {
|
||||
if (userRepository.existsByEmail(user.username)) throw UserEmailAlreadyExistsException("A user with the same email already exists: ${user.username}")
|
||||
if (userRepository.existsByEmailIgnoreCase(user.username)) throw UserEmailAlreadyExistsException("A user with the same email already exists: ${user.username}")
|
||||
|
||||
val komgaUser = KomgaUser(
|
||||
email = user.username,
|
||||
|
|
|
|||
Loading…
Reference in a new issue