Auth Hooks
Auth hooks fire during your app-user authentication lifecycle — registration, login, profile updates, and deletions. Configure them in Dashboard → App Users → Auth Hooks.
pre_login and pre_register are blocking — your function can reject the operation by returning {"block": true, "reason": "..."}. All other auth hooks are fire-and-forget (background).
Events
pre_register
Fires before a new user is saved to the database. Blocking — can reject registration.
Use it to: enforce invite-only signups, validate email domain, check against a blocklist, enforce registration quotas.
Payload:
To block registration, return:
To allow it, return anything else (or nothing):
Example — invite-only: only allow pre-approved emails:
Example — block disposable email domains:
post_register
Fires after a user is successfully registered. Runs in the background.
Use it to: send a welcome email, create default records for the user, notify an admin, add the user to a mailing list.
Payload:
Example — create a default profile record on signup:
Example — send a Slack notification to your team on new signup:
pre_login
Fires after the user’s password is verified but before the JWT token is issued (and before 2FA). Blocking — can deny login.
Use it to: block suspended/banned accounts, enforce geo/IP restrictions, require additional conditions, audit login attempts.
Payload:
To block login, return:
To allow it, return anything else:
Fail-open: If your cloud function times out (10 second limit), crashes, or is unreachable, login proceeds normally. A broken hook will never lock users out of your app.
Example — block banned users:
Example — block users with expired subscriptions:
Example — enforce company email domain after login:
Example — log login to external analytics (allow always):
post_login
Fires after a user logs in and receives their token. Runs in the background.
Use it to: update last_login_at, track login streaks, send a security notification email, refresh cached user data.
Payload:
Example — update last login timestamp and increment counter:
pre_user_update
Fires before a user’s profile is updated. Runs in the background.
Payload:
Example — log profile changes to an audit trail:
post_user_update
Fires after a user’s profile is successfully updated. Runs in the background.
Payload:
Example — sync updated name to a profiles collection:
pre_user_delete
Fires before a user is deleted. Runs in the background.
Use it to: archive the user’s data, clean up associated records, cancel subscriptions, send a goodbye email.
Payload:
Example — archive user data before deletion:
post_user_delete
Fires after a user is successfully deleted. Runs in the background.
Use it to: clean up remaining references, update statistics, notify downstream services.
Payload:
Example — delete all posts authored by the deleted user:
Checking the Event Inside One Function
If you want one cloud function to handle multiple auth events:
Summary Table