Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove side-effect in User crdate getter #606

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Classes/Controller/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
4 changes: 0 additions & 4 deletions Classes/Domain/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Loading