pub struct Auth { /* private fields */ }Expand description
Sign-in for one application. Cheap to clone.
Implementations§
Source§impl Auth
impl Auth
Sourcepub fn from_env(db: Db, app_name: &str) -> Result<Self>
pub fn from_env(db: Db, app_name: &str) -> Result<Self>
Reads the settings above. app_name names the app in emails and to
passkey prompts.
Sourcepub async fn send_code(&self, email: &str) -> Result<()>
pub async fn send_code(&self, email: &str) -> Result<()>
Emails a new sign-in code to email (which must be normalized, see
normalize_email); earlier codes stop working.
Sourcepub async fn verify_code(&self, email: &str, code: &str) -> Result<bool>
pub async fn verify_code(&self, email: &str, code: &str) -> Result<bool>
Whether code is the live code for email. A correct code is used up.
Sourcepub async fn create_session(
&self,
user_id: i64,
customer: bool,
) -> Result<String>
pub async fn create_session( &self, user_id: i64, customer: bool, ) -> Result<String>
Starts a session for user_id and returns its token.
Sourcepub async fn session(&self, token: &str) -> Result<Option<Session>>
pub async fn session(&self, token: &str) -> Result<Option<Session>>
The live session for token, renewed for 30 days when it is past half
its life.
Sourcepub async fn end_session(&self, token: &str) -> Result<()>
pub async fn end_session(&self, token: &str) -> Result<()>
Ends the session for token (signing out).
Sourcepub async fn passkey_register_start(
&self,
user_id: i64,
email: &str,
) -> Result<Challenge>
pub async fn passkey_register_start( &self, user_id: i64, email: &str, ) -> Result<Challenge>
Starts adding a passkey for a signed-in user.
Sourcepub async fn passkey_register_finish(
&self,
user_id: i64,
id: &str,
credential: Value,
) -> Result<()>
pub async fn passkey_register_finish( &self, user_id: i64, id: &str, credential: Value, ) -> Result<()>
Finishes adding a passkey: credential is the browser’s
PublicKeyCredential.toJSON().
Sourcepub async fn passkey_login_start(&self) -> Result<Challenge>
pub async fn passkey_login_start(&self) -> Result<Challenge>
Starts signing in with a passkey (the browser offers the user’s own).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Auth
impl !UnwindSafe for Auth
impl Freeze for Auth
impl Send for Auth
impl Sync for Auth
impl Unpin for Auth
impl UnsafeUnpin for Auth
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Mutably borrows from an owned value. Read more