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

useResendVerifyEmail

Resend a verification email, with a countdown while the API is throttling resends.

useResendVerifyEmail asks the API to send a verification email again, for a new account or for a pending change of address. When the API is throttling resends, it counts down the seconds until another can be sent.

const { resendVerifyEmail, submitting, success, error, retryIn } = useResendVerifyEmail()

Signature

useResendVerifyEmail()

It takes no parameters.

Return Values

ReturnTypePurpose
resendVerifyEmail(username: string, type?: 'current' | 'new') => Promise<void>'current', the default, calls cwa.auth.resendVerifyEmail(). 'new' calls resendVerifyNewEmail(), for a pending change of address
submittingRef<boolean>true while the request runs
successRef<boolean>true once the email has been sent. Reset to false when a new request starts
errorRef<string | undefined>A message for the visitor; see below
retryInRef<number>Seconds until another email can be sent, counting down to 0 after a 429

Error Messages

Situationerror
No username givenPlease enter a username
404Username not found
429, sent recentlyA confirmation email was already sent. You can send another in 4 minutes. (or "shortly" when the wait can't be read)
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

The wait comes from the response's Retry-After header. With an API on another origin, the header must be in the CORS expose_headers, or the message says "shortly" and retryIn stays 0. The countdown stops when the component's scope is disposed.

Example

<button type="button" :disabled="submitting || retryIn > 0" @click="resendVerifyEmail(username)">
  Resend email<template v-if="retryIn"> ({{ retryIn }}s)</template>
</button>

Authentication → Email Verification covers the API's resend limits.