feature #9: Add routes for login

This commit is contained in:
2019-08-22 23:23:25 +02:00
parent 4e9f737e00
commit 5542eede27
9 changed files with 115 additions and 5 deletions

View 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
)
}
}