CWA 2.0 is in alpha: try it, build with it, give feedback. APIs can still change between releases; see Releases.
Auth

useForgotPassword

State and a submit function for a form that requests a password reset email.

useForgotPassword requests a password reset email for a username. The layer's /forgot-password page uses it.

const { credentials, doSubmit, submitting, success, error } = useForgotPassword()

Signature

useForgotPassword()

It takes no parameters.

Return Values

ReturnTypePurpose
credentials{ username: string }A reactive() object. Bind the input to credentials.username
doSubmit() => Promise<void>Calls cwa.auth.forgotPassword(), which sends GET /password/reset/request/{username}. After a success, calling it again navigates to /login
submittingRef<boolean>true while the request runs
successRef<boolean>true once the email has been requested
errorRef<string | undefined>A message for the visitor; see below

Error Messages

Situationerror
No username enteredPlease enter a username
404Username not found
429, a reset was requested recentlyA reset email was already sent recently. Please check your inbox and spam folder.
503, the email couldn't be sentThe email couldn't be sent. Please try again.
400, the API refused to send itThe email couldn't be sent. Please contact the site administrator. The console also logs a warning about the API's user.email_links.allowed_origins
Anything elseThe API's message, its status text, or Unexpected error

There's no countdown after a 429, because the API's wait defaults to 24 hours (password_reset.repeat_ttl_seconds). See Throttled and Failed Email Requests.

Example

Authentication → Password Reset shows both steps of a reset.