Passwords
Learn about password management features in Nile Auth
Features
- Password reset
- Password policies
- Password hashing and security
Overview
With an SMTP provider configured on your database, users with emails can reset their passwords with a two step process. First, the users requests a link to be sent to their email address. The auth service creates a token (saved to the auth.verification_tokens
table in your database), and sends it in an email. The token is valid for 4 hours by default.
Installation
Usage
/user/reset-password
Once the user clicks on the link, they will be redirected to your app and will be able to securely reset their password.
/user/change-password
API
PasswordResetRequestForm
Props
Name | Type | Default | Description |
---|---|---|---|
client | QueryClient (optional) | undefined | React Query client instance. |
callbackUrl | string (optional) | undefined | The URL to redirect to after a successful password reset. |
defaultValues | object (optional) | { email: '', password: '', confirmPassword: '' } | Default form values. |
beforeMutate | (data: AllowedAny) => AllowedAny (optional) | undefined | Function executed before mutation to modify request data. |
onSuccess | (res: Response) => void (optional) | undefined | Callback triggered on successful password reset. |
onError | (error: Error, data: AllowedAny) => void (optional) | undefined | Callback triggered if the reset process fails. |
PasswordResetForm
Props
Name | Type | Default | Description |
---|---|---|---|
client | QueryClient (optional) | undefined | React Query client instance. |
callbackUrl | string (optional) | undefined | The URL to redirect to after a successful password reset. |
defaultValues | object (optional) | { email: '', password: '', confirmPassword: '' } | Default form values. |
beforeMutate | (data: AllowedAny) => AllowedAny (optional) | undefined | Function executed before mutation to modify request data. |
onSuccess | (res: Response) => void (optional) | undefined | Callback triggered on successful password reset. |
onError | (error: Error, data: AllowedAny) => void (optional) | undefined | Callback triggered if the reset process fails. |
Internal Functionality
- Uses
useForm
from React Hook Form to handle form state. - Calls
useResetPassword
with the provided email and password upon form submission. - Implements password confirmation validation to ensure the user inputs matching passwords.
- Supports lifecycle hooks (
beforeMutate
,onSuccess
,onError
) for request customization. - Disables the submit button if passwords do not match or required fields are missing.
Related Topics
Was this page helpful?