Reviewed-on: #1 Co-authored-by: aarbit <aarbit@gmail.com> Co-committed-by: aarbit <aarbit@gmail.com>
20 lines
846 B
Kotlin
20 lines
846 B
Kotlin
package net.halfbinary.scavengerhuntapi.service
|
|
|
|
import net.halfbinary.scavengerhuntapi.error.exception.LoginFailedException
|
|
import net.halfbinary.scavengerhuntapi.model.converter.toDomain
|
|
import net.halfbinary.scavengerhuntapi.model.domain.Hunter
|
|
import net.halfbinary.scavengerhuntapi.model.domain.Login
|
|
import net.halfbinary.scavengerhuntapi.repository.HunterRepository
|
|
import org.slf4j.LoggerFactory
|
|
import org.springframework.stereotype.Service
|
|
|
|
@Service
|
|
class LoginService(private val hunterRepository: HunterRepository) {
|
|
companion object {
|
|
private val log = LoggerFactory.getLogger(LoginService::class.java)
|
|
}
|
|
fun login(login: Login): Hunter {
|
|
log.info("Logging in with email: ${login.email}")
|
|
return hunterRepository.login(login.email, login.password)?.toDomain()?:throw LoginFailedException()
|
|
}
|
|
} |