Skip to main content

Account

Struct Account 

Source
pub struct Account {
Show 13 fields pub id: String, pub user_id: String, pub provider_id: String, pub account_id: String, pub access_token: Option<String>, pub refresh_token: Option<String>, pub id_token: Option<String>, pub access_token_expires_at: Option<u64>, pub refresh_token_expires_at: Option<u64>, pub scope: Option<String>, pub password: Option<String>, pub created_at: u64, pub updated_at: u64,
}
Expand description

A persisted account link. Schema-aligned with better-auth’s account table (verified against https://www.better-auth.com/docs/concepts/database at the time of writing) so users migrating from better-auth see the same field names + meanings:

  • provider_id — the provider’s name ("google", "github", plus "credential" once email/password auth lands). Matches better-auth’s providerId.
  • account_id — the PROVIDER’S ID for the user (Google sub, GitHub numeric id, or for email/password the user’s own id). Matches better-auth’s accountId. NOT the row PK.
  • id — the row PK, generated. Lets the row be referenced independently of the (provider_id, account_id) natural key.
  • password — bcrypt/argon2 hash for provider_id="credential" rows; None for OAuth links. Reserves the column so adding email/password auth doesn’t need a schema migration.

Account vs. user: a single User row can have many Account rows (Google + GitHub + a password — all linked to one pylon user). Provider lookup is by (provider_id, account_id) — NOT email — so a user changing their Google address keeps the same pylon account.

Fields§

§id: String§user_id: String§provider_id: String

Provider name — "google", "github", "credential", etc. (better-auth: providerId)

§account_id: String

Provider’s id for the user — Google sub, GitHub numeric id, or for provider_id="credential" the user’s own id. (better-auth: accountId)

§access_token: Option<String>§refresh_token: Option<String>§id_token: Option<String>§access_token_expires_at: Option<u64>

Unix epoch seconds at which access_token expires. None for non-expiring tokens (GitHub Classic apps) or for password rows.

§refresh_token_expires_at: Option<u64>

Unix epoch seconds at which refresh_token expires. None when the provider doesn’t expire refresh tokens (most don’t, but Microsoft Identity Platform does after 90 days of inactivity).

§scope: Option<String>§password: Option<String>

Bcrypt/argon2 hash for email/password rows. None for OAuth. Always None today — present so adding password auth later doesn’t require a schema migration.

§created_at: u64

Unix epoch seconds when this account was first linked.

§updated_at: u64

Unix epoch seconds when the token bundle was last refreshed.

Implementations§

Source§

impl Account

Source

pub fn new(user_id: String, info: &UserInfo, tokens: &TokenSet) -> Self

Build a new account link from a freshly-completed OAuth handshake. Generates a fresh row id; the (provider_id, account_id) pair is what later lookups key on.

Source

pub fn access_token_expired(&self) -> bool

True if access_token_expires_at is set and has passed. Non-expiring tokens (GitHub Classic) report false — caller should treat them as “valid until proven otherwise” and refresh on 401.

Trait Implementations§

Source§

impl Clone for Account

Source§

fn clone(&self) -> Account

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Account

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Account

Source§

fn eq(&self, other: &Account) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Account

Source§

impl StructuralPartialEq for Account

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V