Enforce password change event only if set #102
This commit is contained in:
@ -147,17 +147,16 @@ class Bootstrap implements BootstrapInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attach an event to check if the password has expired
|
// Attach an event to check if the password has expired
|
||||||
Event::on(SecurityController::class, FormEvent::EVENT_AFTER_LOGIN, function (FormEvent $event) {
|
if (!is_null(Yii::$app->getModule('user')->maxPasswordAge)) {
|
||||||
if (is_null(Yii::$app->getModule('user')->maxPasswordAge)) {
|
Event::on(SecurityController::class, FormEvent::EVENT_AFTER_LOGIN, function (FormEvent $event) {
|
||||||
return;
|
$user = $event->form->user;
|
||||||
}
|
if ($user->password_age >= Yii::$app->getModule('user')->maxPasswordAge) {
|
||||||
$user = $event->form->user;
|
// Force password change
|
||||||
if ($user->password_age >= Yii::$app->getModule('user')->maxPasswordAge) {
|
Yii::$app->session->setFlash('warning', Yii::t('usuario', 'Your password has expired, you must change it now'));
|
||||||
// Force password change
|
Yii::$app->response->redirect(['/user/settings/account'])->send();
|
||||||
Yii::$app->session->setFlash('warning', Yii::t('usuario', 'Your password has expired, you must change it now'));
|
}
|
||||||
Yii::$app->response->redirect(['/user/settings/account'])->send();
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if ($app instanceof WebApplication) {
|
if ($app instanceof WebApplication) {
|
||||||
// override Yii
|
// override Yii
|
||||||
|
|||||||
Reference in New Issue
Block a user