- password validation
Some checks failed
CI Pipeline / lint-and-test (pull_request) Failing after 1m16s
Some checks failed
CI Pipeline / lint-and-test (pull_request) Failing after 1m16s
- Adding and refactoring tests
This commit is contained in:
parent
a8f30d7ef2
commit
aabf94941a
|
|
@ -33,10 +33,10 @@ fun isValidPassword(password: String): Boolean {
|
|||
}
|
||||
|
||||
fun Application.configureRouting(repository: KidioRepository, jwtService : JwtService) {
|
||||
fun Application.configureRouting(
|
||||
fun Application.configureRouting(
|
||||
repository: KidioRepository,
|
||||
jwtService: JwtService,
|
||||
) {
|
||||
) {
|
||||
routing {
|
||||
post("/api/v1/auth/register") {
|
||||
val registerRequest = call.receive<RegisterRequest>()
|
||||
|
|
@ -117,8 +117,6 @@ fun Application.configureRouting(
|
|||
return@post
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
authenticate("auth-jwt") {
|
||||
|
|
@ -135,7 +133,10 @@ fun Application.configureRouting(
|
|||
val principal = call.principal<UserPrincipal>()
|
||||
val userId = principal?.userId
|
||||
if (userId == null) {
|
||||
call.respond(HttpStatusCode.Unauthorized, mapOf("error" to "Ungültiges oder abgelaufenes Token"))
|
||||
call.respond(
|
||||
HttpStatusCode.Unauthorized,
|
||||
mapOf("error" to "Ungültiges oder abgelaufenes Token")
|
||||
)
|
||||
return@post
|
||||
}
|
||||
val taskInfo = repository.getTaskAnswerAndReward(request.taskId)
|
||||
|
|
@ -199,7 +200,8 @@ fun Application.configureRouting(
|
|||
|
||||
// Wir holen die echte, fälschungssichere userId aus dem Login-Token:
|
||||
val principal = call.principal<UserPrincipal>()
|
||||
val userId = principal?.userId ?: request.userId // Fallback auf request.userId, falls token noch fehlt
|
||||
val userId =
|
||||
principal?.userId ?: request.userId // Fallback auf request.userId, falls token noch fehlt
|
||||
|
||||
val currentSeconds = repository.getScreentime(userId)
|
||||
var newSeconds = currentSeconds - request.usedSecondsSinceLastSync
|
||||
|
|
@ -216,5 +218,6 @@ fun Application.configureRouting(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue