PHPackages                             zakharov-andrew/yii2-user - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. zakharov-andrew/yii2-user

ActiveYii2-extension[Authentication &amp; Authorization](/categories/authentication)

zakharov-andrew/yii2-user
=========================

Yii2 User

v0.7.6(3mo ago)5417[1 issues](https://github.com/ZakharovAndrew/yii2-user/issues)2MITPHPPHP &gt;=7.2

Since Apr 25Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/ZakharovAndrew/yii2-user)[ Packagist](https://packagist.org/packages/zakharov-andrew/yii2-user)[ RSS](/packages/zakharov-andrew-yii2-user/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (77)Used By (2)

Yii2 user
=========

[](#yii2-user)

[![Yii2 user module by Zakharov Andrey](docs/img/yii-2-user-module-Zakharov-Andrey.png)](docs/img/yii-2-user-module-Zakharov-Andrey.png)

[![Latest Stable Version](https://camo.githubusercontent.com/d00fc5cc08452789a1fb5e567957cfd695d48b36a2812448292e23c22c297ff1/68747470733a2f2f706f7365722e707567782e6f72672f7a616b6861726f762d616e647265772f796969322d757365722f762f737461626c65)](https://packagist.org/packages/zakharov-andrew/yii2-user)[![Total Downloads](https://camo.githubusercontent.com/03bb147bb19efb369e3306b6788a882496dbc0833c4817b9bf027887335650e5/68747470733a2f2f706f7365722e707567782e6f72672f7a616b6861726f762d616e647265772f796969322d757365722f646f776e6c6f616473)](https://packagist.org/packages/zakharov-andrew/yii2-user)[![License](https://camo.githubusercontent.com/931dda6213e37c6fab095bdc007320f9c7eb351b7a6057df2e88a5f748246cfb/68747470733a2f2f706f7365722e707567782e6f72672f7a616b6861726f762d616e647265772f796969322d757365722f6c6963656e7365)](https://packagist.org/packages/zakharov-andrew/yii2-user)[![Yii2](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](http://www.yiiframework.com/)

Yii2 user authentication module for management users and their rights.

- Registration, authorization, password recovery, change email and so on
- User administration interface
- Supports role creation
- Multiple user roles are supported
- Happy Birthday widgets
- Birthday Calendar widget
- User Deputies Management
- logging of failed authorization attempts and blocking access via IP
- Supports languages: English, Russian

🚀 Installation
--------------

[](#-installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require zakharov-andrew/yii2-user

```

or add

```
"zakharov-andrew/yii2-user": "*"

```

to the `require` section of your `composer.json` file.

Subsequently, run

```
./yii migrate/up --migrationPath=@vendor/zakharov-andrew/yii2-user/migrations

```

in order to create the settings table in your database.

Or add to console config

```
return [
    // ...
    'controllerMap' => [
        // ...
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationPath' => [
                '@console/migrations', // Default migration folder
                '@vendor/zakharov-andrew/yii2-user/src/migrations'
            ]
        ]
        // ...
    ]
    // ...
];
```

🛠 Usage
-------

[](#-usage)

Add this to your main configuration's modules array

```
    'modules' => [
        'user' => [
            'class' => 'ZakharovAndrew\user\Module',
            'bootstrapVersion' => 5, // if use bootstrap 5
            'showTitle' => true, // display H1 headings (default - true)
            'enableUserSignup' => false, //Toggles user registration functionality (default - false)
            'telegramToken' => '', // necessary for the bot to work
            'telegramBotLink' => 'https://t.me/YOUR_BOT_NAME_FOR_USER_LINK', //change!
            // use for menu and access
            'controllersAccessList' => [
                1001 => [
                            'Users' => [
                                '/user/user/index' => 'users',
                                '/user/user/create' => 'create user',
                            ],
                        ],
                1002 => ['/user/roles/index' => 'Roles']
            ],
            'wallpapers' => [
                [
                    'url' => 'path/to/wallpaper1.jpg',
                    'roles' => ['user', 'admin'], // available to which roles
                ],
                [
                    'url' => 'path/to/wallpaper2.jpg',
                    'roles' => ['admin'], // only for admin
                ],
            // ...
            ],
        ],
        // ...
    ],
```

Add this to your `config\params.php`

```
return [
    // ...
    'supportEmail' => 'change-this-email@test.com',
    // lifetime of the password reset token
    'userResetPasswordTokenExpire' => 3600
    // ...
];
```

**If a pretty URL is enabled:**

Add this to your main configuration's urlManager array

```
'urlManager' => [
    //...
    'rules' => [
        'login' => 'user/user/login',
        'logout' => 'user/user/logout',
        'profile' => 'user/user/profile',
        'signup' => 'user/user/signup',
        'wallpapers' => 'user/wallpaper/index',
        //...
    ],
    //...
],
```

📊 Controller Action Logging
---------------------------

[](#-controller-action-logging)

The module provides comprehensive controller action logging for auditing and debugging purposes. When enabled, it automatically logs all controller actions with detailed information.

**Features:**

- ✅ User tracking - Logs user ID for authenticated users
- ✅ Action details - Records controller, action, and HTTP method
- ✅ Request data - Captures request parameters (sensitive data filtered)
- ✅ Performance metrics - Measures execution time
- ✅ Security information - Logs IP address and user agent
- ✅ Response codes - Records HTTP response status codes

### Configuration

[](#configuration)

Enable logging in module configuration:

```
'modules' => [
    'user' => [
        'class' => 'ZakharovAndrew\user\Module',
        'enableControllerLogging' => true, // Enable logging
        // ... other configurations
    ],
],
```

### What Gets Logged

[](#what-gets-logged)

FieldDescription`user_id`User ID (if authenticated)`controller`Controller name`action`Action name`method`HTTP method (GET, POST, etc.)`url`Request URL`request_params`Request parameters (passwords/tokens filtered)`response_code`HTTP response status code`execution_time`Action execution time in seconds`ip_address`Client IP address`user_agent`Client browser/user agent### Sensitive Data Protection

[](#sensitive-data-protection)

The logging system automatically filters sensitive information:

- Passwords (password, password\_hash, etc.)
- Authentication tokens (auth\_key, access\_token, etc.)
- Security codes (cvv, security\_code, etc.)
- Sensitive fields are replaced with ***HIDDEN*** in the logs.

🎉 Happy Birthday widget
-----------------------

[](#-happy-birthday-widget)

You can use the birthday greeting widget by customizing both the header and the message indicating that there are no birthdays today:

```

```

Widget for congratulating the user on his birthday:

```
