reafctor: all code without stream
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CreateApiKeyRequest {
|
||||
pub user_id: Uuid,
|
||||
pub name: String,
|
||||
pub roles: Vec<KeyRole>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum KeyRole {
|
||||
User,
|
||||
Admin,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AuthContext {
|
||||
pub user_id: Uuid,
|
||||
pub _api_key_id: Uuid,
|
||||
pub roles: Vec<KeyRole>,
|
||||
}
|
||||
|
||||
impl AuthContext {
|
||||
pub fn has_role(&self, role: &KeyRole) -> bool {
|
||||
self.roles.iter().any(|r| r == role)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user