Overview
The password reset process consists of two steps:- Send Reset Link - Request a password reset link via email
- Reset Password - Submit new password with the reset token
Both endpoints do not require authentication (unauthenticated).
Step 1: Send Reset Link
Endpoint
Request Body
User’s email address. Must exist in the system.Validation:
required|email|exists:users,emailCode Examples
Success Response
HTTP Status:200 OK
Error Responses
Validation Error - Email Required
HTTP Status:422 Unprocessable Entity
Validation Error - Invalid Email Format
HTTP Status:422 Unprocessable Entity
Validation Error - Email Not Found
HTTP Status:422 Unprocessable Entity
Email Send Failure
HTTP Status:500 Internal Server Error
Returned when the email cannot be sent (e.g., mail server issues).
Source: AuthController.php:182-183
Implementation Details
The send reset link process (fromAuthController.php:160-184):
- Validate Email - Ensures email exists in the database
- Generate Token - Creates a unique reset token
- Send Email - Dispatches password reset email via Laravel’s Password facade
- Return Response - Confirms email was sent
AuthController.php:160-184
Step 2: Reset Password
Endpoint
Request Body
User’s email address.Validation:
required|emailNew password. Minimum 8 characters. Must be confirmed.Validation:
required|confirmed|min:8Password confirmation. Must match the
password field.Validation: Must match password fieldThe reset token received via email.Validation:
requiredCode Examples
Success Response
HTTP Status:200 OK
Content-Type: text/html
Returns an HTML view (auth.reset-password) with a success message.
Source: AuthController.php:252
The view includes:
- Success message: “Your password has been reset!”
- Notification sent to user’s email confirming password change
Error Responses
Invalid User
HTTP Status:200 OK
Content-Type: text/html
Returns HTML view with error message.
Error Message: “We can’t find a user with that email address.”
Source: AuthController.php:227
Invalid Token
HTTP Status:200 OK
Content-Type: text/html
Returns HTML view with error message.
Error Message: “This password reset token is invalid.”
Source: AuthController.php:228
Token Expired
Reset tokens expire after a configured time period (typically 60 minutes). Error Message: “This password reset token is invalid.” (same as invalid token)Validation Errors
HTTP Status:422 Unprocessable Entity
Returned when request data fails validation.
Implementation Details
The password reset process (fromAuthController.php:198-253):
- Validate Request - Validates email, password, confirmation, and token
- Verify Token - Checks if token is valid and not expired
- Reset Password - Updates user’s password with bcrypt hashing
- Generate Remember Token - Creates new remember token for the user
- Fire Event - Triggers
PasswordResetevent - Send Notification - Emails user confirming password change
- Return View - Displays success or error message
AuthController.php:198-253
After successful password reset, users receive a confirmation email via
PasswordResetSuccessNotification. This helps detect unauthorized password changes.Password Reset Flow Diagram
Token Security
Token Expiration
Password reset tokens expire after a configured time period (default: 60 minutes). This is configured inconfig/auth.php:
Token Storage
Tokens are stored in thepassword_reset_tokens table with:
- Email address
- Hashed token
- Creation timestamp
Rate Limiting
Password reset requests are throttled to prevent abuse:- Throttle: 60 seconds between requests for the same email
- Prevents spam and brute force attacks
Best Practices
Secure token transmission
Secure token transmission
Always send password reset links via HTTPS. Never transmit tokens over unencrypted connections.
Use short expiration times
Use short expiration times
Keep token expiration times short (30-60 minutes) to minimize the window for token abuse.
Notify users of password changes
Notify users of password changes
Always send confirmation emails after successful password resets to alert users of potential unauthorized access.
Implement rate limiting
Implement rate limiting
Throttle password reset requests to prevent abuse and protect user accounts.
Generic error messages
Generic error messages
Consider using generic error messages (e.g., “If that email exists, we’ve sent a reset link”) to prevent user enumeration.
Common Issues
Email Not Received
Possible causes:- Email in spam folder
- Invalid email configuration on server
- Email service rate limits
- Email doesn’t exist in system
- Check spam/junk folder
- Verify SMTP configuration
- Contact system administrator
Token Expired
Cause: Token older than configured expiration time (default: 60 minutes) Solution: Request a new password reset linkInvalid Token
Possible causes:- Token already used
- Token manually modified
- Token from different environment
Related Endpoints
Login
Login after resetting password
Register
Create a new account
Update Password
Change password while authenticated