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

Delete email authentication token only after initial checks. #1701

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions module/VuFind/src/VuFind/Auth/EmailAuthenticator.php
Expand Up @@ -214,11 +214,6 @@ public function authenticate($hash)
throw new AuthException('authentication_error_expired');
}
$linkData = json_decode($row['data'], true);
$row->delete();

if (time() - strtotime($row['created']) > $this->loginRequestValidTime) {
throw new AuthException('authentication_error_expired');
}

// Require same session id or IP address:
$sessionId = $this->sessionManager->getId();
Expand All @@ -228,6 +223,14 @@ public function authenticate($hash)
throw new AuthException('authentication_error_session_ip_mismatch');
}

// Only delete the token now that we know the requester is correct. Otherwise
// it may end up deleted due to e.g. safe link check by the email server.
$row->delete();

if (time() - strtotime($row['created']) > $this->loginRequestValidTime) {
throw new AuthException('authentication_error_expired');
}

return $linkData['data'];
}

Expand Down