Expand description
Signing in without a password. Fizzy sends a code to an email address and, once the
person types it back, hands out a session token for crate::CookieAuth.
The two steps are one exchange as far as Fizzy is concerned: creating the session sets
a pending_authentication_token cookie naming the address the code went to, and
redeeming the code has to send that cookie back or the code is refused. The flow keeps
the token between the calls, and hands it out for a caller that has to finish in
another process — a CLI that prompts for the code on its next run.
use fizzy_sdk::{Client, Config, MagicLinkFlow};
let flow = MagicLinkFlow::new(Config::default())?;
flow.create_session("jane@example.com").await?;
// ... the person reads the code out of their email ...
let session = flow.redeem(code).await?;
let client = Client::builder(Config::default())
.session_token(session.session_token.clone())
.build()?;§Where this parts company with the model
The Smithy model spells RedeemMagicLink’s body as {"token": …} and says nothing of
the cookie; upstream Fizzy reads code and requires the cookie. The flow follows
upstream, since that is what answers, and sends both spellings of the code so it also
works against a server built from the model as written. The generated
crate::services::sessions::SessionsService::redeem_magic_link is the model’s shape and
cannot complete a login on its own until the model catches up.
Structs§
- Magic
Link Flow - A sign-in in progress.
Constants§
- PENDING_
COOKIE - The cookie a pending sign-in is carried in between creating the session and redeeming the code.