pub trait AccountBackend: Send + Sync {
// Required methods
fn upsert(&self, account: &Account);
fn find_by_provider(
&self,
provider_id: &str,
account_id: &str,
) -> Option<Account>;
fn find_for_user(&self, user_id: &str) -> Vec<Account>;
fn unlink(&self, provider_id: &str, account_id: &str) -> bool;
fn list_all(&self) -> Vec<Account>;
}Expand description
Pluggable storage for account links. In-memory default ships with
the crate; SQLite + Postgres impls live in pylon-runtime.
Required Methods§
Sourcefn upsert(&self, account: &Account)
fn upsert(&self, account: &Account)
Insert or refresh an account link. The (provider_id, account_id)
pair is the natural key — repeated calls for the same pair
update the token bundle and updated_at on the existing row.
Sourcefn find_by_provider(
&self,
provider_id: &str,
account_id: &str,
) -> Option<Account>
fn find_by_provider( &self, provider_id: &str, account_id: &str, ) -> Option<Account>
Find an account by provider identity. Returns None if the user
hasn’t linked this provider yet.
Sourcefn find_for_user(&self, user_id: &str) -> Vec<Account>
fn find_for_user(&self, user_id: &str) -> Vec<Account>
Every account linked to a user. The /api/auth/me endpoint uses
this to render “you’re connected via Google + GitHub” in the UI
and to gate “unlink” affordances behind “user has another way to
sign in” checks.