Interface: Auth
Authentication configuration and lifecycle hooks.
See the Auth overview for the
supported auth methods and how the User entity is connected to auth.
If hooks are async, Wasp awaits them. All hooks receive prisma and req
in their input. Hook return values are ignored except for
AuthHooks.onBeforeOAuthRedirect, which can change the redirect URL.
Extends
AuthHooks
Properties
methods
methods:
AuthMethods
Enabled authentication methods.
onAfterEmailVerified?
optionalonAfterEmailVerified?:Reference<AnyFunction>
Called once, after the user verifies their email. Receives email and user.
Inherited from
AuthHooks.onAfterEmailVerified
onAfterLogin?
optionalonAfterLogin?:Reference<AnyFunction>
Called after a successful login. Receives providerId, user, and, for
social auth, oauth fields including tokens and the unique OAuth request
ID.
Inherited from
AuthHooks.onAfterLogin
onAfterSignup?
optionalonAfterSignup?:Reference<AnyFunction>
Called after the user is created. Receives providerId, the created
user, and, for social auth, oauth fields including tokens and the
unique OAuth request ID.
Inherited from
AuthHooks.onAfterSignup
onAuthFailedRedirectTo
onAuthFailedRedirectTo:
string
Route that Wasp redirects unauthenticated users to when they try to
access a page that has authRequired: true.
onAuthSucceededRedirectTo?
optionalonAuthSucceededRedirectTo?:string
Route that Wasp redirects users to after a successful login or signup.
Only takes effect when using Wasp's built-in Auth UI.
Default
"/"
onBeforeLogin?
optionalonBeforeLogin?:Reference<AnyFunction>
Called before the user is logged in. Receives providerId and user.
Throw from this hook to reject a login based on custom criteria.
Inherited from
AuthHooks.onBeforeLogin
onBeforeOAuthRedirect?
optionalonBeforeOAuthRedirect?:Reference<AnyFunction>
Called before redirecting the user to the OAuth provider. Receives the
generated url and oauth.uniqueRequestId. Return { url } to override
the redirect URL.
Inherited from
AuthHooks.onBeforeOAuthRedirect
onBeforeSignup?
optionalonBeforeSignup?:Reference<AnyFunction>
Called before the user is created. Receives providerId plus the common
hook input. Throw from this hook to reject a signup based on custom
criteria.
Inherited from
AuthHooks.onBeforeSignup
userEntity
userEntity:
string
Name of the Prisma model that represents the application user connected to your business logic.
The model must be defined in schema.prisma and have an @id field. The
ID can use any Prisma-supported ID type.