Start to build edit user form
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
pub mod app_config;
|
||||
pub mod entity_manager;
|
||||
pub mod service;
|
||||
pub mod session_identity;
|
||||
pub mod user;
|
||||
pub mod client;
|
||||
|
@ -1,2 +0,0 @@
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
|
||||
pub struct ServiceID(String);
|
@ -1,5 +1,5 @@
|
||||
use crate::data::client::ClientID;
|
||||
use crate::data::entity_manager::EntityManager;
|
||||
use crate::data::service::ServiceID;
|
||||
use crate::utils::err::Res;
|
||||
|
||||
pub type UserID = String;
|
||||
@ -18,10 +18,17 @@ pub struct User {
|
||||
|
||||
/// None = all services
|
||||
/// Some([]) = no service
|
||||
pub authorized_services: Option<Vec<ServiceID>>,
|
||||
pub authorized_services: Option<Vec<ClientID>>,
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn can_access_app(&self, id: &ClientID) -> bool {
|
||||
match &self.authorized_services {
|
||||
None => true,
|
||||
Some(c) => c.contains(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verify_password<P: AsRef<[u8]>>(&self, pass: P) -> bool {
|
||||
verify_password(pass, &self.password)
|
||||
}
|
||||
@ -47,7 +54,7 @@ impl Default for User {
|
||||
need_reset_password: false,
|
||||
enabled: true,
|
||||
admin: false,
|
||||
authorized_services: None,
|
||||
authorized_services: Some(Vec::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user