From 8aff5c8008ffd41f8e802d8418c93bcf7220b4d7 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Fri, 4 Nov 2022 00:12:42 +0100 Subject: [PATCH] format log messages in exception class --- src/Application/Controller/Admin/d3user_webauthn.php | 2 +- src/Application/Controller/Admin/d3webauthnadminlogin.php | 4 ++-- src/Application/Controller/d3_account_webauthn.php | 2 +- src/Application/Controller/d3webauthnlogin.php | 2 +- src/Application/Model/Exceptions/WebauthnException.php | 2 +- .../Application/Component/d3_webauthn_UserComponent.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Application/Controller/Admin/d3user_webauthn.php b/src/Application/Controller/Admin/d3user_webauthn.php index eb02879..6feddac 100755 --- a/src/Application/Controller/Admin/d3user_webauthn.php +++ b/src/Application/Controller/Admin/d3user_webauthn.php @@ -72,7 +72,7 @@ class d3user_webauthn extends AdminDetailsController $this->setAuthnRegister(); } catch (Exception|ContainerExceptionInterface|NotFoundExceptionInterface|DoctrineDriverException $e) { Registry::getUtilsView()->addErrorToDisplay($e); - Registry::getLogger()->error('webauthn creation request: '.$e->getMessage(), ['UserId' => $this->getEditObjectId()]); + Registry::getLogger()->error($e->getMessage(), ['UserId' => $this->getEditObjectId()]); Registry::getLogger()->debug($e->getTraceAsString()); Registry::getUtils()->redirect('index.php?cl=d3user_webauthn'); } diff --git a/src/Application/Controller/Admin/d3webauthnadminlogin.php b/src/Application/Controller/Admin/d3webauthnadminlogin.php index 5c80040..a909fb3 100755 --- a/src/Application/Controller/Admin/d3webauthnadminlogin.php +++ b/src/Application/Controller/Admin/d3webauthnadminlogin.php @@ -87,7 +87,7 @@ class d3webauthnadminlogin extends AdminController } catch (WebauthnException $e) { Registry::getSession()->setVariable(WebauthnConf::GLOBAL_SWITCH, true); Registry::getUtilsView()->addErrorToDisplay($e); - Registry::getLogger()->error('webauthn request options: '.$e->getDetailedErrorMessage(), ['UserId' => $userId]); + Registry::getLogger()->error($e->getDetailedErrorMessage(), ['UserId' => $userId]); Registry::getLogger()->debug($e->getTraceAsString()); $this->getUtils()->redirect('index.php?cl=login'); } @@ -122,7 +122,7 @@ class d3webauthnadminlogin extends AdminController } } catch (WebauthnException $e) { Registry::getUtilsView()->addErrorToDisplay($e); - Registry::getLogger()->error('Webauthn: '.$e->getDetailedErrorMessage(), ['UserId' => $userId]); + Registry::getLogger()->error($e->getDetailedErrorMessage(), ['UserId' => $userId]); Registry::getLogger()->debug($e->getTraceAsString()); $user->logout(); $this->getUtils()->redirect('index.php?cl=login'); diff --git a/src/Application/Controller/d3_account_webauthn.php b/src/Application/Controller/d3_account_webauthn.php index 5e2eac8..23b1808 100755 --- a/src/Application/Controller/d3_account_webauthn.php +++ b/src/Application/Controller/d3_account_webauthn.php @@ -78,7 +78,7 @@ class d3_account_webauthn extends AccountController $this->setAuthnRegister(); $this->setPageType('requestnew'); } catch (WebauthnException $e) { - Registry::getLogger()->error('webauthn register: '.$e->getDetailedErrorMessage(), ['UserId: ' => $this->getUser()->getId()]); + Registry::getLogger()->error($e->getDetailedErrorMessage(), ['UserId: ' => $this->getUser()->getId()]); Registry::getLogger()->debug($e->getTraceAsString()); Registry::getUtilsView()->addErrorToDisplay($e); } diff --git a/src/Application/Controller/d3webauthnlogin.php b/src/Application/Controller/d3webauthnlogin.php index d6cfd9d..1442a86 100755 --- a/src/Application/Controller/d3webauthnlogin.php +++ b/src/Application/Controller/d3webauthnlogin.php @@ -87,7 +87,7 @@ class d3webauthnlogin extends FrontendController $this->addTplParam('webauthn_publickey_login', $publicKeyCredentialRequestOptions); } catch (WebauthnException $e) { Registry::getSession()->setVariable(WebauthnConf::GLOBAL_SWITCH, true); - Registry::getLogger()->error('webauthn request options: '.$e->getDetailedErrorMessage(), ['UserId' => $userId]); + Registry::getLogger()->error($e->getDetailedErrorMessage(), ['UserId' => $userId]); Registry::getLogger()->debug($e->getTraceAsString()); Registry::getUtilsView()->addErrorToDisplay($e); $this->getUtils()->redirect('index.php?cl=start'); diff --git a/src/Application/Model/Exceptions/WebauthnException.php b/src/Application/Model/Exceptions/WebauthnException.php index 46c8767..94982fa 100644 --- a/src/Application/Model/Exceptions/WebauthnException.php +++ b/src/Application/Model/Exceptions/WebauthnException.php @@ -43,6 +43,6 @@ class WebauthnException extends StandardException */ public function setDetailedErrorMessage(string $detailedErrorMessage = null): void { - $this->detailedErrorMessage = $detailedErrorMessage; + $this->detailedErrorMessage = 'Webauthn: '.$detailedErrorMessage; } } \ No newline at end of file diff --git a/src/Modules/Application/Component/d3_webauthn_UserComponent.php b/src/Modules/Application/Component/d3_webauthn_UserComponent.php index 0439270..ef49df7 100755 --- a/src/Modules/Application/Component/d3_webauthn_UserComponent.php +++ b/src/Modules/Application/Component/d3_webauthn_UserComponent.php @@ -199,7 +199,7 @@ class d3_webauthn_UserComponent extends d3_webauthn_UserComponent_parent } catch (WebauthnException $e) { Registry::getUtilsView()->addErrorToDisplay($e); Registry::getLogger()->error( - 'Webauthn: '.$e->getDetailedErrorMessage(), + $e->getDetailedErrorMessage(), ['UserId' => Registry::getSession()->getVariable(WebauthnConf::WEBAUTHN_SESSION_CURRENTUSER)] ); Registry::getLogger()->debug($e->getTraceAsString());