pub struct AccountGate {
pub account: String,
pub reason: GateReason,
pub holder: String,
pub actor: String,
pub note: String,
pub at: UnixMillis,
pub expires: Option<UnixMillis>,
}Expand description
One account, locked.
Keyed in the identity table by AccountGate::account, which is a
principal id — and therefore also the namespace that principal
intrinsically owns (crate::AuthTable::owns_account). One row covers both
senses of “this user is locked out” because in gunnar they are the same
name.
Fields§
§account: StringThe principal id, which is also the account namespace.
reason: GateReasonWhy it is gated: somebody decided (GateReason::Administrative, no
deadline) or a purge holds it (GateReason::Purge, with expires).
holder: StringWho set it: a principal id for an operator, a job id for a purge. Read
back by crate::AuthTable::lift_gate_held_by, which is what stops a
finishing purge from lifting somebody else’s suspension.
actor: StringThe principal that asked, for the audit trail. A purge records the
principal that called Accounts.Purge, not the worker thread.
note: StringFree text, shown to the locked-out user. Not optional in practice: a refusal with no reason is a support ticket.
at: UnixMillisWhen it was set.
expires: Option<UnixMillis>None for an administrative gate — it never expires on its own.
Some for a purge lease; see PURGE_LEASE_MS.
Implementations§
Source§impl AccountGate
impl AccountGate
Sourcepub fn administrative(
account: impl Into<String>,
actor: impl Into<String>,
note: impl Into<String>,
) -> Self
pub fn administrative( account: impl Into<String>, actor: impl Into<String>, note: impl Into<String>, ) -> Self
A gate a person or a service set, with no deadline.
Sourcepub fn purge_lease(
account: impl Into<String>,
job_id: impl Into<String>,
expires: UnixMillis,
) -> Self
pub fn purge_lease( account: impl Into<String>, job_id: impl Into<String>, expires: UnixMillis, ) -> Self
A purge’s lease, expiring at expires.
Takes the deadline rather than computing now + PURGE_LEASE_MS so a
test can hand it a time in the past and see the expiry rule fire, which
is the only way to observe the property that keeps an account from being
bricked by a crash.
Sourcepub fn by(self, actor: impl Into<String>) -> Self
pub fn by(self, actor: impl Into<String>) -> Self
Record the principal that asked for the purge, for the audit trail.
Sourcepub fn noted(self, note: impl Into<String>) -> Self
pub fn noted(self, note: impl Into<String>) -> Self
Replace the note shown to the locked-out user.
Sourcepub fn is_live_at(&self, now: UnixMillis) -> bool
pub fn is_live_at(&self, now: UnixMillis) -> bool
Is this gate in force at now?
The one place the deadline is read, so an expired lease cannot be in force for the ACL and absent from the listing, or the other way round (one implementation).
Sourcepub fn is_live(&self) -> bool
pub fn is_live(&self) -> bool
AccountGate::is_live_at against the wall clock.