web-id/ail

认证页面,在调试模式下轻松更改用户

1.0.2 2022-11-29 09:01 UTC

README

Latest Version on Packagist Total Downloads

认证页面,轻松更改用户

Ail homepage

安装

1/ Composer

您可以通过 composer 安装此包

composer require web-id/ail

2/ 包安装

使用以下命令安装包(配置文件和视图)

php artisan ail:install

3/ 配置

更新配置,特别是 guardallowedEnv

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

return [
    /*
    |--------------------------------------------------------------------------
    | Route configuration
    |--------------------------------------------------------------------------
    |
    | These values will change the route configuration for the application routes.
    | You can define the prefix, the name and set your own middleware on it.
    | Web middleware is required for authentication and CanImpersonate for security.
    |
    */

    'routes' => [
        'prefix' => 'ail',
        'name' => 'ail',
        'middlewares' => [
            'web',
            CanImpersonate::class,
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | Guards to display
    |--------------------------------------------------------------------------
    |
    | This value is a list of guards that you want to display and impersonate. You
    | need to set the name on key and the service builder on value. The service
    | builder is required for search bar on view. By default, you can use
    | SearchUser::class that search on `name` attribute. You are free and encouraged
    | to create your own service.
    |
    */

    'guards' => [
        'web' => SearchUser::class,
    ],

    /*
    |--------------------------------------------------------------------------
    | Allowed environment security
    |--------------------------------------------------------------------------
    |
    | This value is a list of environments authorized for this package. It will
    | use APP_ENV. WARNING : This package is not recommended on risky environments
    | like production or preprod with sensitive data.
    */

    'allowedEnv' => [
        'local',
        'preproduction',
    ],

    /*
    |--------------------------------------------------------------------------
    | Pagination
    |--------------------------------------------------------------------------
    |
    | This value is the pagination number for view.
    |
    */

    'perPage' => 15,
];

4/ 更新模型

在您想要冒充的 Authenticatable 模型上添加 Impersonate 特性。

class User extends Authenticatable
{
    use Impersonate;
}

5/ 更新视图

您可以在 resources/views/vendors/ail 中添加自己的逻辑。

默认情况下,它将显示 name 属性。

6/ 更多选项

见: https://github.com/404labfr/laravel-impersonate

警告:不要忘记设置授权,以确定谁可以冒充: https://github.com/404labfr/laravel-impersonate#defining-impersonation-authorization

默认情况下,所有用户都可以被冒充。

更新日志

有关最近更改的更多信息,请参阅 CHANGELOG

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件