feat(perms): consistently throw correct permissions

This commit is contained in:
Paul Makles
2022-02-22 21:41:12 +00:00
parent 7befd77c5b
commit 4c40c6c2cc
33 changed files with 134 additions and 264 deletions

View File

@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use revolt_quark::{
models::{Server, User},
perms, Db, Error, Ref, Result,
perms, Db, Permission, Ref, Result,
};
#[derive(Serialize, Deserialize)]
@@ -26,16 +26,12 @@ pub async fn req(
data: Json<Data>,
) -> Result<Json<Server>> {
let mut server = target.as_server(db).await?;
if !perms(&user)
perms(&user)
.server(&server)
.calc(db)
.await
.can_manage_permissions()
{
return Err(Error::NotFound);
}
.throw_permission(db, Permission::ManagePermissions)
.await?;
// ! FIXME: calculate permission against role
// ! FIXME_PERMISSIONS
server
.set_role_permission(