Skip to main content

AccountBackend

Trait AccountBackend 

Source
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>;

    // Provided method
    fn delete_for_user(&self, user_id: &str) -> usize { ... }
}
Expand description

Pluggable storage for account links. In-memory default ships with the crate; SQLite + Postgres impls live in pylon-runtime.

Required Methods§

Source

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.

Source

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.

Source

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.

Remove a single provider link. Returns true if a row was removed.

Source

fn list_all(&self) -> Vec<Account>

Every account in the store. Used by AccountStore::list_all_unfiltered to power the Studio admin inspector. Backends that can stream (SQLite, Postgres) just SELECT *; the in-memory backend returns its full map.

Provided Methods§

Source

fn delete_for_user(&self, user_id: &str) -> usize

Remove every account link for a user. Used during account deletion to ensure no OAuth references survive past a user row delete. Default implementation walks find_for_user + unlink; SQL backends can override with a single DELETE.

Implementors§