sh4msi / filament-otp
Filament OTP 是 Filament 的一个包,允许用户使用一次性密码登录。(OTP和无密码登录相似,但在某些方面有所不同!)
v1.0.1
2023-12-03 15:37 UTC
Requires
- php: ^8.1
- filament/filament: ^3.0
- illuminate/contracts: ^10.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-08 20:15:21 UTC
README
Filament OTP 是 Filament 3 的一个包,允许用户使用一次性密码登录。(OTP和无密码登录相似,但在某些方面有所不同!)
安装
您可以通过 composer 安装此包
composer require sh4msi/filament-otp
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="filament-otp-config"
可选地,您可以使用以下命令发布视图
php artisan vendor:publish --tag="filament-otp-views"
这是已发布配置文件的内容
return [ /** * The authentication model to use. */ 'user_model' => \App\Models\User::class, /** * login columns */ 'login_key' => 'email', 'login_key_rule' => ['email', 'required'], /** * token resend countdown time */ 'resent_token_countdown_time' => 60, /** * token count */ 'token_count' => 5, /** * token type * number, string, etc */ 'token_type' => 'number', /** * token expiry (minutes) */ 'token_expiry' => 15, /** * Rate limit count */ 'rate_limit_count' => 3, /** * Rate limit decay seconds */ 'rate_limit_decay_seconds' => 30, /** * Token generator class must implement TokenGeneratorInterface */ 'token_generator' => \Sh4msi\FilamentOtp\Utility\TokenGenerator::class, /** * Token notification class */ 'token_notification' => \Sh4msi\FilamentOtp\Notifications\NotificationOTP::class, /** * Login confirmation page component * * If you want to change something, place your component here. */ 'confirm_token_component' => \Sh4msi\FilamentOtp\Http\Livewire\Auth\ConfirmOTP::class, 'login_otp_component' => \Sh4msi\FilamentOtp\Http\Livewire\Auth\LoginOTP::class, ];
用法
将 Sh4msi\FilamentOtp\Traits\OtpLogin 特性添加到您的用户模型中
use Illuminate\Foundation\Auth\User as Authenticatable; use Sh4msi\FilamentOtp\Traits\OtpLogin; class User extends Authenticatable { use OtpLogin; // ... }
您可以在面板配置对象中使用 renderHook() 方法在登录页面上显示“使用一次性密码登录”按钮。
use Filament\Panel; use Illuminate\Contracts\View\View; public function panel(Panel $panel): Panel { return $panel // ... ->renderHook( 'panels::auth.login.form.after', fn (): View => View('filament-otp::livewire.login-otp-btn'), ) }
或通过路由调用
route('filament-otp.login')
变更日志
请参阅变更日志获取最近更改的更多信息。
贡献
请参阅贡献指南获取详细信息。
安全漏洞
请查看我们的安全策略了解如何报告安全漏洞。
鸣谢
许可证
MIT 许可证(MIT)。请参阅许可证文件获取更多信息。