taha-moghaddam/filament-otp-login
Pros:
?mobile=...) simplifies stateless architectures (e.g., serverless backends or microservices).Cons:
Login class). May need middleware tweaks for stateless routes.OtpSenderInterface implementations may introduce latency or failures (e.g., SMS API timeouts). No built-in retry logic or fallback mechanisms.?mobile=...) could expose sensitive data in logs or browser history. OTP resend limits (default: 3) may be insufficient for brute-force attacks.encrypt() for URL parameters, and enforce stricter rate-limiting (e.g., via throttle middleware).mobile column exists in the user table. Migrations or schema changes may be needed for existing apps.Auth::attempt()).Preparation:
mobile column to user table (if missing). Example migration:
Schema::table('users', function (Blueprint $table) {
$table->string('mobile')->unique()->nullable()->after('email');
});
App\Models\User implements HasMobile trait or extends Filament’s FilamentUser (if using Filament).OtpSenderInterface for the chosen provider (e.g., Twilio, Vonage). Example:
use TahaMoghaddam\FilamentOtpLogin\Contracts\OtpSenderInterface;
class TwilioOtpSender implements OtpSenderInterface {
public function send(string $mobile, string $otp): void {
// Twilio logic here
}
}
filament-otp-login.php) for:
otp_length (default: 6)request_block_seconds (default: 60)max_resend_attempts (default: 3)otp_sender (bind the custom sender in AppServiceProvider).Integration:
routes/web.php:
use TahaMoghaddam\FilamentOtpLogin\Http\Controllers\OtpLoginController;
Route::get('/login/mobile', [OtpLoginController::class, 'showMobileForm'])->name('filament-otp-login.mobile');
Route::post('/login/mobile', [OtpLoginController::class, 'verifyMobile']);
Route::get('/login/otp', [OtpLoginController::class, 'showOtpForm'])->name('filament-otp-login.otp');
EnsureMobileIsVerified or custom middleware if needed.app/Providers/Filament/AdminPanelProvider.php:
public function panel(Panel $panel): Panel {
return $panel
->login()
->pages([
\TahaMoghaddam\FilamentOtpLogin\Pages\OtpLogin::class,
]);
}
Testing:
OtpSenderInterface to test OTP generation/validation.Deployment:
request_block_seconds based on real-world usage.OtpLoginPage) to match app branding.OtpSenderInterface (e.g., AWS SNS, Plivo,How can I help you explore Laravel packages today?