Skip to content

Commit

Permalink
fix: 修复获得板块权限接口的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nullaqua committed Sep 11, 2024
1 parent 26586f0 commit d2145ff
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/kotlin/subit/router/Block.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,14 @@ private suspend fun Context.getPermission()
val bid = call.parameters["id"]?.toBlockIdOrNull() ?: return call.respond(HttpStatus.BadRequest)
val uid = call.parameters["user"]?.toUserIdOrNull() ?: return call.respond(HttpStatus.BadRequest)
val blocks = get<Blocks>()
val user = SSO.getDbUser(uid) ?: return call.respond(HttpStatus.NotFound)
withPermission {
withPermission()
{
checkCanRead(blocks.getBlock(bid) ?: return call.respond(HttpStatus.NotFound))
checkHasAdminIn(bid)
if (uid != UserId(0)) checkHasAdminIn(bid)
}
val user =
if (uid == UserId(0)) getLoginUser()?.toDatabaseUser()
else SSO.getDbUser(uid)
call.respond(HttpStatus.OK, withPermission(user) { getPermission(bid) })
}

Expand Down

0 comments on commit d2145ff

Please sign in to comment.