Skip to main content

Module email_code

Module email_code 

Source
Expand description

One-time email codes for sign-up and login, kept in the visitor’s session. Nothing touches the tenant or user tables until the address is verified, and a code only works in the browser that asked for it.

Structs§

PendingCode
The code a session is waiting on. Only a salted hash of it is stored. The count of wrong guesses is not kept here: a session is a per-request copy, so a counter in it is lost under concurrent guesses. check counts guesses in the shared, serialized rate limiter instead.
VerifiedEmail
An address whose code was entered correctly.

Enums§

CheckOutcome
Purpose
Which form asked for the code.

Constants§

CODE_DIGITS
CODE_VALID_FOR
MAX_ATTEMPTS

Functions§

check
A correct code consumes the pending entry and marks the address verified.
clear_verified
Forgets the verified address once it has been used.
pending
The code this session is waiting on, expired or not, so the page can still offer a resend.
start
Starts (or restarts) verification for email and returns the code to send.
verified
The address verified in this session, while still fresh.