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;
}
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.

Implementors§