feature #9: Add routes for login
This commit is contained in:
19
src/main/kotlin/fr/dcproject/repository/User.kt
Normal file
19
src/main/kotlin/fr/dcproject/repository/User.kt
Normal file
@@ -0,0 +1,19 @@
|
||||
package fr.dcproject.repository
|
||||
|
||||
import fr.postgresjson.connexion.Requester
|
||||
import fr.postgresjson.repository.RepositoryI
|
||||
import io.ktor.auth.UserPasswordCredential
|
||||
import fr.dcproject.entity.User as UserEntity
|
||||
|
||||
class User(override var requester: Requester) : RepositoryI<UserEntity> {
|
||||
override val entityName = UserEntity::class
|
||||
|
||||
fun findByCredentials(credentials: UserPasswordCredential): UserEntity? {
|
||||
return requester
|
||||
.getFunction("check_user")
|
||||
.selectOne(
|
||||
"username" to credentials.name,
|
||||
"plain_password" to credentials.password
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user