Giter VIP home page Giter VIP logo

filament-renew-password's Introduction

Filament Renew Password Plugin

The Filament Renew Password Plugin enhances Filament by prompting users to renew their passwords based on specified criteria.

Screenshot

Installation

  1. Install the package using the composer command:
composer require mei-labs/fi-renew-password
  1. Publish the associated vendor files and run the migration, which adds a new column last_renew_password_at to the users table.
php artisan vendor:publish
php artisan migrate

Alternatively, if you don't want to publish the migrations or already have a column in your database for such case, you can skip this step and customize the column name by using any of the configuration methods described in the Configuration section below.

  1. Register the plugin in your panel provider:
use MeiLABS\Filament\RenewPassword\RenewPasswordPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
       ->plugin(new RenewPasswordPlugin());
}

Configuration

Filament Renew Password Plugin is designed to work out of the box with minimal configuration. However, you can customize the plugin by publishing the configuration file, changing the environment variables or using the plugin object to override the default settings.

Via Plugin Configuration

// app/Providers/Filament/YourPanelServiceProvider.php

RenewPasswordPlugin::make()
    ->timestampColumn('password_changed_at')
    ->passwordExpiresIn(days: 30)

Via Environment Variables

// .env

FILAMENT_RENEW_PASSWORD_DAYS_PERIOD=30
FILAMENT_RENEW_PASSWORD_TIMESTAMP_COLUMN=last_renew_password_at

Via Configuration File

// config/filament-renew-password.php

return [
    'timestamp_column' => 'password_changed_at',
    'password_expires_in' => 30,
];

Any of the above methods will work. The plugin will use the configuration in the following order of priority: Plugin Configuration, Environment Variables, Configuration File.

Usage

  1. Implement the RenewPasswordContract on your Authentication Model (User) and define the criteria for prompting password renewal in the needRenewPassword function.

Example for a 90-day renewal period:

class User extends Authenticatable implements RenewPasswordContract
{
    ... 
    
    public function needRenewPassword(): bool
    {
        return Carbon::parse($this->last_renew_password_at ?? $this->created_at)->addDays(90) < now();
    }
}

Alternatively, you can use the RenewPassword trait on your Authentication Model (User). By default, the trait uses the configured column and a 90-day renewal period. You can customize the column name and renewal period by configuring the plugin.

class User extends Authenticatable implements RenewPasswordContract
{
    use RenewPassword;
}

filament-renew-password's People

Contributors

codewithmei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.