kda/filament-wimdy

3.0.4 2024-05-03 14:32 UTC

This package is auto-updated.

Last update: 2024-05-03 12:37:59 UTC


README

Latest Version on Packagist Total Downloads

wimdy

about

it's an extension for jeffgreco13/filament-breezy that brings two features

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

Installation

You can install the package via composer:


breezy


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

You will have to publish and run the migrations with:

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

You can publish the config file with:

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

This is the contents of the published config file:

<?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

change your filament auth config to


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

and add \KDA\Filament\Wimdy\Middleware\ForcePasswordChange::class to your filament middleware like

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

User Model

add 'force_password_change' and 'enabled' to your fillable attributes

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

Admin panel

Just add two toggles to your UserResource Form

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

Just add two columns to your table

    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'),

Credits

License

The MIT License (MIT). Please see License File for more information.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.