pub struct AuthToken {
pub token_hash: String,
pub purpose: TokenPurpose,
pub user_id: String,
pub panel: String,
pub email: Option<String>,
pub expires_at: Timestamp,
pub created_at: Timestamp,
}Expand description
Shipped single-use secret record: the SHA-256 hash of the token a mailed link or a pending sign-in carries, what it is for, the account and the panel it acts on, and its expiry. The raw token is never stored.
Fields§
§token_hash: StringHex-encoded SHA-256 of the token.
purpose: TokenPurposeWhat the token does when used.
user_id: StringPanelUser::user_id of the account the token acts on.
panel: StringThe prefix of the panel that issued the token: the only panel it works on.
email: Option<String>The address a link proves the account reads, for a purpose that proves one.
expires_at: Timestamp§created_at: TimestampImplementations§
Source§impl AuthToken
impl AuthToken
Sourcepub fn fields() -> AuthTokenFields<AuthToken>
pub fn fields() -> AuthTokenFields<AuthToken>
Returns a handle used to reference AuthToken’s fields when building query expressions.
Sourcepub async fn get_by_token_hash(
executor: &mut dyn Executor,
token_hash: impl IntoExpr<<String as Field>::ExprTarget>,
) -> Result<AuthToken, Error>
pub async fn get_by_token_hash( executor: &mut dyn Executor, token_hash: impl IntoExpr<<String as Field>::ExprTarget>, ) -> Result<AuthToken, Error>
Fetches the single AuthToken where token_hash matches, erroring if none exists.
Sourcepub fn update_by_token_hash(
token_hash: impl IntoExpr<<String as Field>::ExprTarget>,
) -> AuthTokenUpdate
pub fn update_by_token_hash( token_hash: impl IntoExpr<<String as Field>::ExprTarget>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where token_hash matches.
Sourcepub async fn delete_by_token_hash(
executor: &mut dyn Executor,
token_hash: impl IntoExpr<<String as Field>::ExprTarget>,
) -> Result<(), Error>
pub async fn delete_by_token_hash( executor: &mut dyn Executor, token_hash: impl IntoExpr<<String as Field>::ExprTarget>, ) -> Result<(), Error>
Deletes the AuthToken where token_hash matches.
Sourcepub fn filter_by_token_hash(
token_hash: impl IntoExpr<<String as Field>::ExprTarget>,
) -> AuthTokenQuery
pub fn filter_by_token_hash( token_hash: impl IntoExpr<<String as Field>::ExprTarget>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where token_hash matches.
Sourcepub async fn get_by_user_id(
executor: &mut dyn Executor,
user_id: impl IntoExpr<<String as Field>::ExprTarget>,
) -> Result<AuthToken, Error>
pub async fn get_by_user_id( executor: &mut dyn Executor, user_id: impl IntoExpr<<String as Field>::ExprTarget>, ) -> Result<AuthToken, Error>
Fetches the single AuthToken where user_id matches, erroring if none exists.
Sourcepub fn update_by_user_id(
user_id: impl IntoExpr<<String as Field>::ExprTarget>,
) -> AuthTokenUpdate
pub fn update_by_user_id( user_id: impl IntoExpr<<String as Field>::ExprTarget>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where user_id matches.
Sourcepub async fn delete_by_user_id(
executor: &mut dyn Executor,
user_id: impl IntoExpr<<String as Field>::ExprTarget>,
) -> Result<(), Error>
pub async fn delete_by_user_id( executor: &mut dyn Executor, user_id: impl IntoExpr<<String as Field>::ExprTarget>, ) -> Result<(), Error>
Deletes the AuthToken where user_id matches.
Sourcepub fn filter_by_user_id(
user_id: impl IntoExpr<<String as Field>::ExprTarget>,
) -> AuthTokenQuery
pub fn filter_by_user_id( user_id: impl IntoExpr<<String as Field>::ExprTarget>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where user_id matches.
Sourcepub async fn get_by_expires_at(
executor: &mut dyn Executor,
expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>,
) -> Result<AuthToken, Error>
pub async fn get_by_expires_at( executor: &mut dyn Executor, expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>, ) -> Result<AuthToken, Error>
Fetches the single AuthToken where expires_at matches, erroring if none exists.
Sourcepub fn update_by_expires_at(
expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>,
) -> AuthTokenUpdate
pub fn update_by_expires_at( expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>, ) -> AuthTokenUpdate
Returns a builder that updates the AuthToken where expires_at matches.
Sourcepub async fn delete_by_expires_at(
executor: &mut dyn Executor,
expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>,
) -> Result<(), Error>
pub async fn delete_by_expires_at( executor: &mut dyn Executor, expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>, ) -> Result<(), Error>
Deletes the AuthToken where expires_at matches.
Sourcepub fn filter_by_expires_at(
expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>,
) -> AuthTokenQuery
pub fn filter_by_expires_at( expires_at: impl IntoExpr<<Timestamp as Field>::ExprTarget>, ) -> AuthTokenQuery
Returns a query selecting the AuthToken records where expires_at matches.
Sourcepub fn create() -> AuthTokenCreate
pub fn create() -> AuthTokenCreate
Returns a builder that inserts a new AuthToken record.
Typically constructed through the toasty::create! macro.
Sourcepub fn create_many() -> CreateMany<AuthToken>
pub fn create_many() -> CreateMany<AuthToken>
Returns a builder that inserts multiple AuthToken records at once.
Sourcepub fn update(&mut self) -> AuthTokenUpdate<&mut AuthToken>
pub fn update(&mut self) -> AuthTokenUpdate<&mut AuthToken>
Returns a builder that updates this AuthToken record in place.
Source§impl AuthToken
impl AuthToken
Sourcepub fn upsert_by_token_hash(
token_hash: impl IntoExpr<<String as Field>::ExprTarget>,
) -> AuthTokenUpsertByTokenHash
pub fn upsert_by_token_hash( token_hash: impl IntoExpr<<String as Field>::ExprTarget>, ) -> AuthTokenUpsertByTokenHash
Returns a builder that creates AuthToken or updates the record whose token_hash constraint matches.
The target arguments initialize a new record and remain unchanged when an existing record is updated.
Trait Implementations§
Source§impl Load for AuthToken
impl Load for AuthToken
Source§fn reload(target: &mut AuthToken, value: Value) -> Result<(), Error>
fn reload(target: &mut AuthToken, value: Value) -> Result<(), Error>
§fn ty_relation() -> Type
fn ty_relation() -> Type
stmt::Type] used when this type appears as a relation
target. The default delegates to ty().§fn load_relation(value: Value) -> Result<Self::Output, Error>
fn load_relation(value: Value) -> Result<Self::Output, Error>
Source§impl Model for AuthToken
impl Model for AuthToken
Source§type Query<__T> = AuthTokenQuery<__T>
type Query<__T> = AuthTokenQuery<__T>
Source§type UpdateQuery = AuthTokenUpdate
type UpdateQuery = AuthTokenUpdate
Source§type PrimaryKey = String
type PrimaryKey = String
Source§type ManyField<__Origin> = AuthTokenListFields<__Origin>
type ManyField<__Origin> = AuthTokenListFields<__Origin>
Source§type OneField<__Origin, __Target> = AuthTokenFields<__Origin, __Target>
type OneField<__Origin, __Target> = AuthTokenFields<__Origin, __Target>
Source§fn register(model_set: &mut ModelSet)
fn register(model_set: &mut ModelSet)
ModelSet]. Read moreSource§fn new_path<__Origin>(
path: Path<__Origin, AuthToken>,
) -> <AuthToken as Model>::Path<__Origin>
fn new_path<__Origin>( path: Path<__Origin, AuthToken>, ) -> <AuthToken as Model>::Path<__Origin>
Path] targeting this model.Source§fn new_many_field<__Origin>(
path: Path<__Origin, List<AuthToken>>,
) -> AuthTokenListFields<__Origin>
fn new_many_field<__Origin>( path: Path<__Origin, List<AuthToken>>, ) -> AuthTokenListFields<__Origin>
ManyField from a path targeting a list
of this model.Source§fn find_by_primary_key(
id: Expr<<AuthToken as Model>::PrimaryKey>,
) -> <AuthToken as Model>::Query<List<AuthToken>>
fn find_by_primary_key( id: Expr<<AuthToken as Model>::PrimaryKey>, ) -> <AuthToken as Model>::Query<List<AuthToken>>
Source§fn wrap_query<__T>(stmt: Query<__T>) -> <AuthToken as Model>::Query<__T>
fn wrap_query<__T>(stmt: Query<__T>) -> <AuthToken as Model>::Query<__T>
Query in this model’s
query builder, preserving the result shape T. This is the single
constructor generic code uses to build any query shape; callers narrow
at the statement level (.one(), .first()) before wrapping.Source§fn query_one(
query: <AuthToken as Model>::Query<List<AuthToken>>,
) -> <AuthToken as Model>::Query<AuthToken>
fn query_one( query: <AuthToken as Model>::Query<List<AuthToken>>, ) -> <AuthToken as Model>::Query<AuthToken>
Source§fn query_first(
query: <AuthToken as Model>::Query<List<AuthToken>>,
) -> <AuthToken as Model>::Query<Option<AuthToken>>
fn query_first( query: <AuthToken as Model>::Query<List<AuthToken>>, ) -> <AuthToken as Model>::Query<Option<AuthToken>>
Source§fn field_name_to_id(name: &str) -> FieldId
fn field_name_to_id(name: &str) -> FieldId
FieldId]. Read more§fn new_root_path() -> Self::Path<Self>
fn new_root_path() -> Self::Path<Self>
§fn path_field<U>(index: usize) -> Path<Self, U>
fn path_field<U>(index: usize) -> Path<Self, U>
Path] from this model to the field at index.§fn path_model_list() -> Path<List<Self>, List<Self>>
fn path_model_list() -> Path<List<Self>, List<Self>>
Path] rooted at a list of this model, used as the root of
has-many relation scopes.§fn new_create() -> Self::Create
fn new_create() -> Self::Create
Source§impl UpdateTarget for &mut AuthToken
impl UpdateTarget for &mut AuthToken
Source§fn to_update_stmt(&mut self, assignments: Assignments) -> Update<AuthToken>
fn to_update_stmt(&mut self, assignments: Assignments) -> Update<AuthToken>
Source§impl ViaTarget for AuthToken
impl ViaTarget for AuthToken
Source§type Query = AuthTokenQuery
type Query = AuthTokenQuery
Source§type Path<__Origin> = <AuthToken as Model>::ManyField<__Origin>
type Path<__Origin> = <AuthToken as Model>::ManyField<__Origin>
#[has_many(via = …)] field’s accessor returns,
parameterized by the origin model. Mirrors Model::Path for the
via-many case. Read moreSource§fn new_path<__Origin>(
path: Path<__Origin, List<AuthToken>>,
) -> <AuthToken as ViaTarget>::Path<__Origin>
fn new_path<__Origin>( path: Path<__Origin, List<AuthToken>>, ) -> <AuthToken as ViaTarget>::Path<__Origin>
Path handle from the typed path reaching this
terminal. A model terminal wraps the path in its chainable ManyField; a
scalar terminal is a leaf, so the path is the handle.Source§fn via_field_ty(singular: Name, path: Path) -> FieldTy
fn via_field_ty(singular: Name, path: Path) -> FieldTy
FieldTy::Via] for a #[has_many(via = …)] field whose
terminal element type is Self. Read moreAuto Trait Implementations§
impl Freeze for AuthToken
impl RefUnwindSafe for AuthToken
impl Send for AuthToken
impl Sync for AuthToken
impl Unpin for AuthToken
impl UnsafeUnpin for AuthToken
impl UnwindSafe for AuthToken
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<M> RelationOneField for Mwhere
M: Model,
impl<M> RelationOneField for Mwhere
M: Model,
§type One = <M as Model>::Query<M>
type One = <M as Model>::Query<M>
<Target as Model>::Query<Target>; for nullable impls it is
<Target as Model>::Query<Option<Target>>.§type Expr = M
type Expr = M
Self::Target for non-nullable impls and
Option<Self::Target> for nullable impls.§fn make_one(
query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>,
) -> <M as RelationOneField>::One
fn make_one( query: <<M as RelationOneField>::Target as Model>::Query<List<<M as RelationOneField>::Target>>, ) -> <M as RelationOneField>::One
Query<Model> for non-nullable impls and
Query<Option<Model>> for nullable impls. Read more§fn reload(target: &mut Self, value: Value) -> Result<(), Error>
fn reload(target: &mut Self, value: Value) -> Result<(), Error>
§fn has_one_relation_field_ty(
pair: Option<FieldId>,
via: Option<Path>,
) -> FieldTy
fn has_one_relation_field_ty( pair: Option<FieldId>, via: Option<Path>, ) -> FieldTy
FieldTy] for a HasOne relation field, given an
optional paired BelongsTo field on the target model resolved
from #[has_one(pair = <field>)]. When None, the linker selects
the pair by searching the target for a unique BelongsTo back to
the source. Read more§fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
fn belongs_to_relation_field_ty(foreign_key: ForeignKey) -> FieldTy
FieldTy] for a BelongsTo relation field, given the
foreign key resolved from the field’s #[belongs_to(...)] attribute.