Páginas · Laravilt
Two-Factor Authentication
TOTP, SMS OTP, and Email OTP second factor methods
Add an extra layer of security with TOTP authenticator apps, SMS, or email verification codes.
Enable in Panel
php
Available Methods
TOTP (Authenticator App)
Time-based One-Time Password with apps like Google Authenticator, Authy, or 1Password.
php
SMS OTP
One-time password sent via SMS:
php
Email OTP
One-time password sent via email:
php
Multiple Methods
php
Migration
php
Configuration
php
Profile Integration
Enable 2FA management in user profile:
php
Recovery Codes
Recovery codes are generated when 2FA is enabled. Users can:
- View recovery codes
- Regenerate recovery codes
- Use recovery code if device is lost
php
Enforcing 2FA
Require 2FA for all users:
php
For specific roles:
php
API Reference
Panel Methods
| Method | Parameters | Description |
|---|---|---|
twoFactorAuthentication() | ?array $methods | Enable 2FA |
required() | — | Require 2FA for all users |
requiredFor() | array $roles | Require 2FA for roles |
User Methods
| Method | Parameters | Description |
|---|---|---|
enableTwoFactor() | string $method | Enable 2FA |
disableTwoFactor() | — | Disable 2FA |
hasTwoFactorEnabled() | — | Check if 2FA enabled |
generateTwoFactorRecoveryCodes() | — | Generate recovery codes |
validateTwoFactorCode() | string $code | Validate TOTP code |
validateTwoFactorRecoveryCode() | string $code | Validate recovery code |