Administrator privileges to get and delete subscribers
This commit is contained in:
@@ -3,6 +3,8 @@ use std::result;
|
||||
use tower_sessions::{Session, session::Error};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::authentication::Role;
|
||||
|
||||
pub struct TypedSession(Session);
|
||||
|
||||
type Result<T> = result::Result<T, Error>;
|
||||
@@ -10,6 +12,7 @@ type Result<T> = result::Result<T, Error>;
|
||||
impl TypedSession {
|
||||
const USER_ID_KEY: &'static str = "user_id";
|
||||
const USERNAME_KEY: &'static str = "username";
|
||||
const ROLE_KEY: &'static str = "role";
|
||||
|
||||
pub async fn renew(&self) -> Result<()> {
|
||||
self.0.cycle_id().await
|
||||
@@ -31,6 +34,14 @@ impl TypedSession {
|
||||
self.0.get(Self::USERNAME_KEY).await
|
||||
}
|
||||
|
||||
pub async fn insert_role(&self, role: Role) -> Result<()> {
|
||||
self.0.insert(Self::ROLE_KEY, role).await
|
||||
}
|
||||
|
||||
pub async fn get_role(&self) -> Result<Option<Role>> {
|
||||
self.0.get(Self::ROLE_KEY).await
|
||||
}
|
||||
|
||||
pub async fn clear(&self) {
|
||||
self.0.clear().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user