feat(daemon): AppState::get_pending_status returns wire-friendly bool+flag
has_pending stays #[cfg(test)] because production GUI reads via the new get_pending_status (one round-trip carries both presence and flag); production PAM module reads the file directly. Method gated with #[allow(dead_code)] until Task 5 wires D-Bus. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,9 @@ use crate::storage::policy::PolicyStore;
|
|||||||
use crate::storage::recovery::{RecoveryEntry, RecoveryStore, RecoveryStoreError};
|
use crate::storage::recovery::{RecoveryEntry, RecoveryStore, RecoveryStoreError};
|
||||||
use crate::storage::userdb::{UserDb, UserDbError};
|
use crate::storage::userdb::{UserDb, UserDbError};
|
||||||
use authforge_common::policy::{Policy, PolicyError};
|
use authforge_common::policy::{Policy, PolicyError};
|
||||||
use authforge_common::types::{Credential, Method, PendingFlag, PolicyApplyResult, Transport};
|
use authforge_common::types::{
|
||||||
|
Credential, Method, PendingFlag, PendingStatus, PolicyApplyResult, Transport,
|
||||||
|
};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -249,12 +251,24 @@ impl AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tests assert pending flag round-trips through SetPendingFlag /
|
/// Tests assert pending flag round-trips through SetPendingFlag /
|
||||||
/// ClearPendingFlag via this read accessor. Production readers (PAM
|
/// ClearPendingFlag via this read accessor. Production readers go
|
||||||
/// module, GUI status) read the on-disk file directly in later phases.
|
/// through `get_pending_status` (GUI) or read the on-disk file
|
||||||
|
/// directly (PAM module).
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub async fn has_pending(&self, user: &str) -> Result<bool, StateError> {
|
pub async fn has_pending(&self, user: &str) -> Result<bool, StateError> {
|
||||||
Ok(self.pending.get(user)?.is_some())
|
Ok(self.pending.get(user)?.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)] // wired through D-Bus in Task 5.
|
||||||
|
pub async fn get_pending_status(&self, user: &str) -> Result<PendingStatus, StateError> {
|
||||||
|
match self.pending.get(user)? {
|
||||||
|
Some(flag) => Ok(PendingStatus { present: true, flag }),
|
||||||
|
None => Ok(PendingStatus {
|
||||||
|
present: false,
|
||||||
|
flag: PendingFlag::default(),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
Reference in New Issue
Block a user