Auth.PasswordReset

Auth

Password-reset tokens.

Mirrors Email.verificationToken with purpose = "password.reset". Compose with Email.send in the app to deliver the link; this module only mints and checks tokens.

Types

Error

type Error = BadToken

Why token verification failed.

Examples

Err Auth.PasswordReset.BadToken

Values

token

token : String -> Int -> String -> String

Mint a reset token for email.

ttlSeconds must be positive. Uses HS256 with secret (same rules as Jwt.signWithExp).

Examples

Auth.PasswordReset.token secret 3600 "ada@example.com"

verify

verify : String -> String -> Result Error String

Verify a token from token.

Returns the email on success. Wrong secret, bad signature, wrong purpose, missing email claim, or expired exp are Err BadToken.

Examples

Auth.PasswordReset.verify secret resetToken

errorToString

errorToString : Error -> String

Human-readable form of an Error for logs.

Examples

Auth.PasswordReset.errorToString BadToken