Overview
The authentication system is configured inconfig/fortify.php:5 and includes:
- User registration
- Login with rate limiting
- Email verification
- Password reset
- Two-factor authentication (2FA)
- Profile management
Fortify Configuration
Authentication Guard
The system uses the standard web guard defined atconfig/fortify.php:18:
Username Field
Authentication is performed using email addresses:Usernames (email addresses) are automatically converted to lowercase before storage to ensure consistency.
Home Path
After successful authentication, users are redirected to the dashboard:User Model
TheUser model is located at app/Models/User.php:12 and extends Laravel’s Authenticatable class.
Traits
- HasFactory: Enables model factories for testing
- Notifiable: Allows sending notifications to users
- TwoFactorAuthenticatable: Adds two-factor authentication capabilities
Fillable Fields
Hidden Fields
Sensitive data hidden from serialization:Field Casting
Authentication Features
Registration
User registration is enabled inconfig/fortify.php:147:
- Name (string)
- Email (unique, valid email format)
- Password (hashed automatically)
New users must verify their email address before accessing protected routes due to the
verified middleware.Login
Login functionality with rate limiting:Email Verification
Email verification is required and enabled atconfig/fortify.php:149:
verified middleware (like /dashboard, /clientes, /vehiculos) require email verification:
Password Reset
Password reset functionality is enabled atconfig/fortify.php:148:
users handles password reset tokens and notifications.
Password Reset Flow
Password Reset Flow
- User requests password reset via email
- System sends reset link to registered email
- User clicks link and provides new password
- Password is hashed and updated in database
- User is redirected to dashboard upon success
Two-Factor Authentication
Two-factor authentication (2FA) is enabled with password confirmation atconfig/fortify.php:150:
- confirm: Requires user confirmation to enable 2FA
- confirmPassword: Requires password confirmation before managing 2FA settings
TwoFactorAuthenticatable trait at app/Models/User.php:15 provides:
- QR code generation
- Recovery code management
- 2FA challenge handling
Recovery codes are automatically generated when enabling 2FA and should be stored securely by the user.
Middleware Protection
Authentication Middleware
Theauth middleware ensures users are logged in:
Verification Middleware
Theverified middleware ensures email addresses are verified:
Profile Management
Profile management routes are defined inroutes/settings.php:6:
Profile Settings
Route:/settings/profile
Middleware: auth
Description: Edit user profile information (name, email)
Password Management
Route:/settings/password
Middleware: auth, verified
Description: Change user password
Two-Factor Authentication
Route:/settings/two-factor
Middleware: auth, verified, password.confirm (conditional)
Description: Enable, disable, and manage 2FA settings
Password confirmation is conditionally applied based on the Fortify configuration.
Appearance Settings
Route:/settings/appearance
Middleware: auth, verified
Description: Customize UI preferences (likely theme, display options)
User Utility Methods
The User model includes a custominitials() method at app/Models/User.php:56:
Security Features
Password Hashing
Passwords are automatically hashed using Laravel’s secure hashing via the
hashed castRate Limiting
Login attempts are throttled to 5 per minute per email/IP combination
Email Verification
Required for accessing sensitive features and data
Two-Factor Auth
Optional additional security layer with TOTP authentication
CSRF Protection
All forms protected by Laravel’s CSRF middleware
Remember Token
Secure persistent login sessions with token rotation
Fortify Routes
Fortify automatically registers the following routes with theweb middleware:
| Method | URI | Description |
|---|---|---|
| GET | /login | Display login form |
| POST | /login | Process login |
| POST | /logout | Logout user |
| GET | /register | Display registration form |
| POST | /register | Process registration |
| GET | /email/verify | Email verification notice |
| GET | /email/verify// | Verify email address |
| POST | /email/verification-notification | Resend verification email |
| GET | /forgot-password | Display forgot password form |
| POST | /forgot-password | Send password reset link |
| GET | /reset-password/ | Display reset password form |
| POST | /reset-password | Process password reset |
| GET | /two-factor-challenge | Display 2FA challenge |
| POST | /two-factor-challenge | Verify 2FA code |
All Fortify routes use the prefix and middleware defined in
config/fortify.php:89 and config/fortify.php:104.