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
| Return | Type | Purpose |
|---|---|---|
resendVerifyEmail | (username: string, type?: 'current' | 'new') => Promise<void> | 'current', the default, calls cwa.auth.resendVerifyEmail(). 'new' calls resendVerifyNewEmail(), for a pending change of address |
submitting | Ref<boolean> | true while the request runs |
success | Ref<boolean> | true once the email has been sent. Reset to false when a new request starts |
error | Ref<string | undefined> | A message for the visitor; see below |
retryIn | Ref<number> | Seconds until another email can be sent, counting down to 0 after a 429 |
Error Messages
| Situation | error |
|---|---|
| No username given | Please enter a username |
404 | Username not found |
429, sent recently | A 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 sent | The email couldn't be sent. Please try again. |
400, the API refused to send it | The 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 else | The 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.