Add disableIpLogging option. (#379)

This commit is contained in:
jkmssoft
2020-04-17 18:10:54 +02:00
committed by GitHub
parent e2b041a32a
commit 369c59bbb1
6 changed files with 12 additions and 2 deletions

View File

@ -141,7 +141,7 @@ class SecurityController extends Controller
if ($form->login()) {
$form->getUser()->updateAttributes([
'last_login_at' => time(),
'last_login_ip' => Yii::$app->request->getUserIP(),
'last_login_ip' => $this->module->disableIpLogging ? '127.0.0.1' : Yii::$app->request->getUserIP(),
]);
$this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event);

View File

@ -125,7 +125,7 @@ class User extends ActiveRecord implements IdentityInterface
if ($insert) {
$this->setAttribute('auth_key', $security->generateRandomString());
if (Yii::$app instanceof Application) {
$this->setAttribute('registration_ip', Yii::$app->request->getUserIP());
$this->setAttribute('registration_ip', $this->module->disableIpLogging ? '127.0.0.1' : Yii::$app->request->getUserIP());
}
}

View File

@ -206,6 +206,10 @@ class Module extends BaseModule
* @var boolean whether to restrict assignment of permissions to users
*/
public $restrictUserPermissionAssignment = false;
/**
* @var boolean whether to disable IP logging into user table
*/
public $disableIpLogging = false;
/**
* @return string with the hit to be used with the give consent checkbox

View File

@ -47,6 +47,7 @@ $module = Yii::$app->getModule('user');
: $model->registration_ip;
},
'format' => 'html',
'visible' => !$module->disableIpLogging,
],
[
'attribute' => 'created_at',
@ -78,6 +79,7 @@ $module = Yii::$app->getModule('user');
: $model->last_login_ip;
},
'format' => 'html',
'visible' => !$module->disableIpLogging,
],
[
'header' => Yii::t('usuario', 'Confirmation'),