Skip to Content
Delmare Digital

Login, sign-up and password reset

The admin login the plugin injects, how it detects which sign-in methods to show, and the standalone forgot- and reset-password views.

When your users collection sets auth.disableLocalStrategy, the plugin replaces Payload's admin login with its own LoginView and adds a logout button. The login view asks Better Auth which methods are available and shows only those: email and password, sign-up, forgot password, magic link and email OTP, social providers, passkeys, and an inline two-factor step.

Users who sign in without the required role see an access-denied screen instead of the admin.

Most options default to 'auto' (show the option if Better Auth has it enabled). Every option is listed under admin.login. If no email-based method is enabled (for example a social-only login), the email form and its button are not rendered.

User registration

The "Create account" link appears when Better Auth has emailAndPassword.enabled: true and does not set disableSignUp: true. Force it with admin.login.enableSignUp.

No configuration is needed for most setups.

New users get their role on the server, never from the sign-up form. The first user becomes an admin and everyone after gets defaultRole; see firstUserAdmin.

Password reset

The "Forgot password?" link appears when Better Auth's password-reset endpoint is available. Force it with admin.login.enableForgotPassword, or send users to your own page with admin.login.resetPasswordUrl.

The reset view removes the ?token= from the URL after reading it, so the token does not stay in browser history, referrers or analytics.

Standalone components

import { ForgotPasswordView, ResetPasswordView } from '@delmaredigital/payload-better-auth/components/auth'

<ForgotPasswordView
  logo={<MyLogo />}
  title="Forgot Password"
  loginPath="/admin/login"
/>

<ResetPasswordView
  logo={<MyLogo />}
  title="Reset Password"
  afterResetPath="/admin/login"
  minPasswordLength={8}
/>

ForgotPasswordView also accepts successMessage and an authClient. It reports success only when the request succeeded; Better Auth already answers unknown emails vaguely on the server.

Edit this page on GitHub

On this page