diff --git a/CHANGELOG.md b/CHANGELOG.md index 5716b649..7833d501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## dev +- Fix: Two Factor Authentication - Filter - Blocks even when two factor authentication is enabled - Fix: update Dutch (nl) translations (squio) - Enh: possibility to limit the depth of the recursion when getting user ids from roles (mp1509) diff --git a/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php b/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php index bcb09dc8..f0d07092 100644 --- a/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php +++ b/src/User/Filter/TwoFactorAuthenticationEnforceFilter.php @@ -38,8 +38,10 @@ public function beforeAction($action) } $permissions = $module->twoFactorAuthenticationForcedPermissions; - $itemsByUser = array_keys($this->getAuthManager()->getItemsByUser(Yii::$app->user->identity->id)); - if (!empty(array_intersect($permissions, $itemsByUser))) { + + $user = Yii::$app->user->identity; + $itemsByUser = array_keys($this->getAuthManager()->getItemsByUser($user->id)); + if (!empty(array_intersect($permissions, $itemsByUser)) && !$user->auth_tf_enabled) { Yii::$app->session->setFlash('warning', Yii::t('usuario', 'Your role requires 2FA, you won\'t be able to use the application until you enable it')); return Yii::$app->response->redirect(['/user/settings/account'])->send(); } diff --git a/src/User/Service/MailService.php b/src/User/Service/MailService.php index 39b52ee2..4e99d443 100644 --- a/src/User/Service/MailService.php +++ b/src/User/Service/MailService.php @@ -83,11 +83,16 @@ public function getType() */ public function run() { - return $this->mailer + $result = $this->mailer ->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params) ->setFrom($this->from) ->setTo($this->to) ->setSubject($this->subject) ->send(); + + if (!$result) { + Yii::error("Email sending failed to '{$this->to}'.", 'mailer'); + } + return $result; } } diff --git a/src/User/Validator/TwoFactorEmailValidator.php b/src/User/Validator/TwoFactorEmailValidator.php index 37bedcef..9466a05e 100644 --- a/src/User/Validator/TwoFactorEmailValidator.php +++ b/src/User/Validator/TwoFactorEmailValidator.php @@ -111,6 +111,6 @@ public function getUnsuccessLoginMessage($codeDurationTime) */ public function generateCode() { - return $this->make(TwoFactorEmailCodeGeneratorService::class, $this->user)->run(); + return $this->make(TwoFactorEmailCodeGeneratorService::class, [$this->user])->run(); } }