kda/filament-wimdy

3.0.8 2024-09-25 15:50 UTC

This package is auto-updated.

Last update: 2024-09-25 13:50:57 UTC


README

Latest Version on Packagist Total Downloads

wimdy

关于

它是 jeffgreco13/filament-breezy 的扩展,增加了两个功能

1: force the user to change his password
2: disable user accounts without deleting them

安装

您可以通过 composer 安装此软件包


breezy


    php  artisan vendor:publish --tag="filament-breezy-config"
    php  artisan vendor:publish --tag="filament-breezy-migrations"

您需要使用以下命令发布和运行迁移

php artisan vendor:publish --provider="KDA\Filament\Wimdy\ServiceProvider" --tag="migrations"
php artisan migrate

您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="KDA\Filament\Wimdy\ServiceProvider" --tag="config"

这是已发布配置文件的内容

<?php
// config for KDA/Filament\Wimdy
return [
    'middleware'=>[
        'exceptions'=>[
            '/admin/password/reset'
        ]
        ],
    'password_forcereset_component_path'=> \KDA\Filament\Wimdy\Http\Livewire\Auth\ForceResetPassword::class
];

Filament

将您的 filament auth 配置更改如下


    'auth' => [
        'guard' => env('FILAMENT_AUTH_GUARD', 'web'),
        'pages' => [
            'login' => \KDA\Filament\Wimdy\Http\Livewire\Auth\Login::class,
        ],
    ],

并将 \KDA\Filament\Wimdy\Middleware\ForcePasswordChange::class 添加到您的 filament 中间件中,例如

    'middleware' => [
        'auth' => [
            Authenticate::class,
            \KDA\Filament\Wimdy\Middleware\ForcePasswordChange::class
        ],
    // rest of the config
    ]   

用户模型

将 'force_password_change' 和 'enabled' 添加到您的 fillable 属性中

    protected $fillable = ['name', 'email', 'password','force_password_change','enabled'];

管理面板

只需将两个切换按钮添加到您的 UserResource 表单中

   Forms\Components\Toggle::make('enabled')->default(true),
   Forms\Components\Toggle::make('force_password_change')->default(true)

只需将两列添加到您的表中

    BooleanColumn::make('enabled'),
    BooleanColumn::make('active')
        ->getStateUsing(fn ($record): bool => ($record->force_password_change && !blank($record->password_changed_on) || !$record->force_password_change)  )
        ->trueColor(fn($record):string => !$record->force_password_change ? 'secondary': 'success'),

鸣谢

许可协议

MIT 许可协议(MIT)。请参阅 许可文件 了解更多信息。

安全漏洞

请查看 我们的安全策略 了解如何报告安全漏洞。