new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Better Auth · all subjects

hooks & middleware

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

beforeEmailVerification callback

The beforeEmailVerification callback runs custom code just before a user's email is marked as verified. It receives the user object and request details as parameters. This is useful for validation, pre-checks, or preparing data before the verification is finalized.

afterEmailVerification callback

The afterEmailVerification callback runs automatically after a user verifies their email. It receives the user object and request details as parameters. This is useful for side-effects like granting access to special features or logging the event.

onExistingUserSignUp callback for duplicate email attempts

The onExistingUserSignUp callback is triggered when someone tries to sign up with an email that already exists. It receives a user object and request details. This callback is only called when emailAndPassword.requireEmailVerification is set to true, which enables the generic duplicate response (synthetic user) instead of throwing a duplicate-email error.

beforeEmailVerification callback example

```ts import { betterAuth } from 'better-auth'; export const auth = betterAuth({ emailVerification: { async beforeEmailVerification(user, request) { console.log(`About to verify ${user.email}`); } } }) ``` This example shows how to run custom code before email verification is completed.

afterEmailVerification callback example

```ts import { betterAuth } from 'better-auth'; export const auth = betterAuth({ emailVerification: { async afterEmailVerification(user, request) { console.log(`${user.email} has been successfully verified!`); } } }) ``` This example shows how to run custom code immediately after successful email verification.

onExistingUserSignUp callback example

```ts import { betterAuth } from 'better-auth'; export const auth = betterAuth({ emailAndPassword: { enabled: true, onExistingUserSignUp: async ({ user }, request) => { console.log(`Someone tried to sign up with ${user.email}`); } } }) ``` This example shows how to handle duplicate sign-up attempts when requireEmailVerification is enabled.

Give your agent this brain