This commit is contained in:
2024-08-27 21:34:18 +02:00
parent cab12fca92
commit c11eaaee45
13 changed files with 118 additions and 373 deletions
+4 -15
View File
@@ -59,28 +59,17 @@ fun Route.configureStats() {
call.respond(list.map { Fight(it.first, it.second, it.third) })
}
route("/user/{id}") {
install(SWPermissionCheck) {
userCheck {
val user = it.call.request.getUser()
val auth = it.call.principal<SWAuthPrincipal>()
if (user == null || auth == null) {
return@userCheck false
}
return@userCheck user.id == auth.user.id || auth.user.hasPerm(UserPerm.MODERATION)
}
}
route("/user") {
install(SWPermissionCheck)
get {
val user = call.request.getUser()
val user = call.authentication.principal<SWAuthPrincipal>()
if (user == null) {
call.respond(HttpStatusCode.NotFound, "User not found")
return@get
}
call.respond(UserStats(user))
call.respond(UserStats(user.user))
}
}
}