Skip to content

EspoCRM – Open Source CRM Application

Inactivate token after secret

Yurii21ea03ec8d5e
diff --git a/application/Espo/Core/Authentication/Authentication.php b/application/Espo/Core/Authentication/Authentication.php
index 28fd9d31c9..4214da2639 100644
--- a/application/Espo/Core/Authentication/Authentication.php
+++ b/application/Espo/Core/Authentication/Authentication.php
@@ -437,18 +437,16 @@ class Authentication
$user = $this->applicationState->getUser();
- $this->authTokenManager->inactivate($authToken);
-
if ($authToken->getSecret()) {
$sentSecret = $request->getCookieParam(self::COOKIE_AUTH_TOKEN_SECRET);
if (
- // Still need the ability to destroy auth tokens of another users
+ // Still need the ability to destroy auth tokens of other users
// for login-as-another-user feature.
$authToken->getUserId() !== $user->getId() &&
$sentSecret !== $authToken->getSecret()
) {
- throw new Forbidden("Can't destroy auth token.");
+ throw new Forbidden("Can't destroy auth token for another user.");
}
if ($sentSecret === $authToken->getSecret()) {
@@ -456,6 +454,8 @@ class Authentication
}
}
+ $this->authTokenManager->inactivate($authToken);
+
$method = $this->methodProvider->get();
if (!$this->logoutFactory->isCreatable($method)) {