Skip to main content
Email verification adds an extra layer of security by ensuring users own the email address they register with.
The email delivery setup below (provider, sender, template, redirect URL) is configured under the email: key of startApp. To run code when verification succeeds or fails, register the onAfterEmailVerification / onEmailVerificationError callbacks under auth: — see Auth Hooks.

Enabling Email Verification

First, configure your email provider (see Email Configuration):

How It Works

  1. When a user signs up, a verification token is generated and stored
  2. An email with a verification link is sent to the user’s email address
  3. The link contains the token: https://yourapp.com/api/_internal/auth/verify-email?token=...
  4. When clicked, the token is validated and the user’s email is marked as verified
  5. The user is redirected to your configured redirectUrl with ?status=verified, or ?status=error&message=... if the link is invalid or expired

Base URL requirement

The verification link is built from your site’s base URL, so you must set it via the _system.site.url config (or the MODELENCE_SITE_URL environment variable). It is never taken from the request’s Host or X-Forwarded-Host header, which the caller controls. Under modelence dev only, an unset base URL defaults to the local server (http://localhost:<port>). Anywhere else, if an email provider is configured and the base URL isn’t set, signup and resending the verification email fail with a clear error, before any account or token is created. Opening the link does not sign the user in, so your redirectUrl page should send them to sign in. Corporate mail scanners often open links before the user does. Opening a link again after it has verified the address still redirects with status=verified, so the user’s own click succeeds. Tokens are stored hashed and expire after 24 hours.

Custom Verification Templates

You can customize the verification email template:

Manual Verification

You can also manually complete email verification from the client using a verification token: Manual verification confirms the email address without creating or replacing the caller’s login session. It triggers the onAfterEmailVerification or onEmailVerificationError hook with session: null and the caller’s connection information, matching the emailed-link route. The default emailed link goes to the server verification route. To use your own verification page, configure email.verification.template to extract the token from the supplied verificationUrl and link to your page with that token. The page should read the token from its URL and call verifyEmail when the user confirms.

Automatic Verification via Password Reset

If a user resets their password and their email was not yet verified, the email is automatically marked as verified upon a successful password reset. Since the user must receive the reset email to complete the flow, this proves ownership of the address. See Password Reset for setup details.

Resending Verification Email

If the user did not receive the original verification email, you can resend it. The email is only sent when the address is registered and not yet verified — a generic response is always returned regardless, to avoid leaking account information. This endpoint enforces the following limits via the verification rate limit bucket:
  • 1 per 60 seconds — per user, a new verification email cannot be sent until 60 seconds have passed since the previous one.
  • 10 per day — per user, a maximum of 10 verification emails can be sent within a 24-hour window.
  • 10 per 15 minutes, 100 per day — per IP, counted on every call whether or not the address is registered, so one client can’t cycle through many addresses.