fix policy_db_get

This commit is contained in:
weisd
2025-02-22 01:05:27 +08:00
parent 391eb5b6f9
commit 704c41b116
2 changed files with 11 additions and 4 deletions
+7 -1
View File
@@ -606,11 +606,17 @@ where
if !policy_present {
let mut m = HashMap::new();
self.api.load_mapped_policy(name, UserType::Reg, true, &mut m).await?;
if let Err(err) = self.api.load_mapped_policy(name, UserType::Reg, true, &mut m).await {
if !is_err_no_such_policy(&err) {
return Err(err);
}
}
if let Some(p) = m.get(name) {
Cache::add_or_update(&self.cache.group_policies, name, p, OffsetDateTime::now_utc());
return Ok((p.to_slice(), p.update_at));
}
return Ok((Vec::new(), OffsetDateTime::now_utc()));
}
return Ok((Vec::new(), OffsetDateTime::now_utc()));
+4 -3
View File
@@ -2,14 +2,15 @@ use serde::Deserialize;
use serde::Serialize;
use time::OffsetDateTime;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "lowercase")]
pub enum GroupStatus {
#[default]
Enabled,
Disabled,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct GroupAddRemove {
pub group: String,
pub members: Vec<String>,
@@ -19,7 +20,7 @@ pub struct GroupAddRemove {
pub is_remove: bool,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct GroupDesc {
pub name: String,
pub status: String,