From be8d8c580bf3b5881a7aa913236a28556ad62399 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Tue, 5 Nov 2024 17:27:44 +0100 Subject: [PATCH] [TASK] Remove side-effect in User crdate getter --- Classes/Controller/AbstractController.php | 2 +- Classes/Controller/EditController.php | 2 +- Classes/Domain/Model/User.php | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index d41434ee2..83aecbbd0 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -469,7 +469,7 @@ protected function redirectByAction( protected function isSpoof(User $user, int $uid, string $receivedToken): bool { $errorOnProfileUpdate = false; - $knownToken = GeneralUtility::hmac((string)$user->getUid(), (string)$user->getCrdate()->getTimestamp()); + $knownToken = GeneralUtility::hmac((string)$user->getUid(), (string)($user->getCrdate() ?: new \DateTime('01.01.1970'))->getTimestamp()); //check if the params are valid if (!is_string($receivedToken) || !hash_equals($knownToken, $receivedToken)) { diff --git a/Classes/Controller/EditController.php b/Classes/Controller/EditController.php index a5ff7613e..9b9cf4e59 100644 --- a/Classes/Controller/EditController.php +++ b/Classes/Controller/EditController.php @@ -39,7 +39,7 @@ public function editAction(): ResponseInterface if ($this->user) { $token = GeneralUtility::hmac( (string)$this->user->getUid(), - (string)$this->user->getCrdate()->getTimestamp() + (string)($this->user->getCrdate() ?: new \DateTime('01.01.1970'))->getTimestamp() ); } $this->view->assignMultiple([ diff --git a/Classes/Domain/Model/User.php b/Classes/Domain/Model/User.php index aebb7ed8d..d11befc57 100644 --- a/Classes/Domain/Model/User.php +++ b/Classes/Domain/Model/User.php @@ -565,10 +565,6 @@ public function setCrdate($crdate) */ public function getCrdate() { - if ($this->crdate === null) { - // timestamp is zero - $this->crdate = new DateTime('01.01.1970'); - } return $this->crdate; }