actually use default permissions, misc
This commit is contained in:
@@ -3,9 +3,10 @@ use sqlx::PgConnection;
|
|||||||
use crate::{database::DatabaseError, users::User};
|
use crate::{database::DatabaseError, users::User};
|
||||||
|
|
||||||
/// Infradmin and systemuser have all permissions.
|
/// Infradmin and systemuser have all permissions.
|
||||||
#[derive(Debug, Clone, PartialEq, strum::IntoStaticStr)]
|
#[derive(Debug, Clone, Copy, PartialEq, strum::IntoStaticStr)]
|
||||||
pub enum Permission {
|
pub enum Permission {
|
||||||
// Pass all the permission checks
|
// Pass all the permission checks
|
||||||
|
// Additionally, only Admins can manage others' permissions.
|
||||||
Admin,
|
Admin,
|
||||||
// All Users have the right to observe their own sessions
|
// All Users have the right to observe their own sessions
|
||||||
ListOthersSessions,
|
ListOthersSessions,
|
||||||
@@ -68,7 +69,7 @@ impl User {
|
|||||||
Ok(self
|
Ok(self
|
||||||
.permission_dbstate(conn, permission)
|
.permission_dbstate(conn, permission)
|
||||||
.await?
|
.await?
|
||||||
.unwrap_or(false))
|
.unwrap_or(permission.is_default_permission()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn grant_permission(
|
pub async fn grant_permission(
|
||||||
|
|||||||
Reference in New Issue
Block a user