Overview
Controllers in Laravel Breeze API handle the business logic for authentication operations. All authentication controllers are located inapp/Http/Controllers/Auth/.
Controller Structure
Each controller extends the baseController class and implements specific authentication functionality.
app/Http/Controllers/Controller.php
Authentication Controllers
RegisteredUserController
Handles user registration. Location:app/Http/Controllers/Auth/RegisteredUserController.php
- Validates name, email, and password
- Enforces email uniqueness
- Hashes password with
Hash::make() - Fires
Registeredevent (triggers email verification) - Automatically logs in the new user
- Returns 204 No Content response
AuthenticatedSessionController
Handles user login and logout. Location:app/Http/Controllers/Auth/AuthenticatedSessionController.php
- Uses custom
LoginRequestfor validation and authentication - Regenerates session ID (prevents session fixation)
- Returns 204 No Content
- Logs out user from web guard
- Invalidates session
- Regenerates CSRF token
- Returns 204 No Content
PasswordResetLinkController
Handles password reset link requests. Location:app/Http/Controllers/Auth/PasswordResetLinkController.php
- Validates email format
- Uses Laravel’s
Passwordfacade to send reset link - Returns JSON response with status message
- Throws validation exception on failure
NewPasswordController
Handles password reset. Location:app/Http/Controllers/Auth/NewPasswordController.php
- Validates token, email, and password
- Uses
Password::reset()to verify token - Updates password and remember token
- Fires
PasswordResetevent - Returns JSON response with status
VerifyEmailController
Handles email verification. Location:app/Http/Controllers/Auth/VerifyEmailController.php
- Single action controller (uses
__invoke) - Checks if email is already verified
- Marks email as verified
- Fires
Verifiedevent - Redirects to frontend with verification status
EmailVerificationNotificationController
Resends email verification notification. Location:app/Http/Controllers/Auth/EmailVerificationNotificationController.php
- Checks if email is already verified
- Sends verification notification
- Returns JSON response with status
Form Request
LoginRequest
Custom form request with authentication logic. Location:app/Http/Requests/Auth/LoginRequest.php
- Validates email and password
- Implements rate limiting (5 attempts per minute)
- Handles authentication logic
- Fires
Lockoutevent when rate limited - Custom throttle key based on email and IP
Response Types
Controllers use different response types based on their purpose:No Content Response
Used for successful mutations without response body:JSON Response
Used for status messages:Redirect Response
Used for email verification:Next Steps
API Routes
Learn about route configuration
Database
Explore models and migrations