theauth.username.handleRequest.
There is no separate email-based password plugin. For email-first sign-in, pair this module with the email verification module and email OTP, or use magic link for a fully passwordless flow.
Setup
lib/theauth.ts
Mount the handler
handleRequest matches the literal pathnames below (/auth/username/sign-up and so on) and only for POST. If you mount it under a prefix such as /api/theauth, strip the prefix from the URL before calling it. theauth.username is null unless the username key is passed and auth.session is configured.
Sign up
POST /auth/username/sign-up
Sign up (client)
400 with a plain-text error message, not a machine-readable code) when the username fails validation or is already taken, or when the password fails length validation.
Sign in
POST /auth/username/sign-in
Sign in (client)
Change password
POST /auth/username/change-password
Requires the caller to know the current password. The module does not read the session for you, pass the authenticated userId from your own session lookup.
Change password (client)
Change username
POST /auth/username/change-username
Change username (client)
allowedPattern, length) apply here too.
Using the module directly
theauth.username exposes typed methods in addition to handleRequest, useful when you want to call sign-up/sign-in from server code (e.g. an admin invite flow) instead of going through HTTP:
Configuration reference
Related
Magic link
Passwordless, email-based alternative when you don’t want a password field at all.
Two-factor auth
Add TOTP as a second factor on top of username/password sign-in.
Authentication overview
All available auth methods and how to combine them.
Sessions
What happens after sign-in: cookie and JWT session management.