Suppress or fix psalm errors related to InvalidTokenException

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/42640/head
Côme Chilliet 2024-01-08 17:47:22 +07:00 committed by Côme Chilliet
parent eee9f1eec4
commit 95ea6188dc
5 changed files with 9 additions and 9 deletions

@ -293,7 +293,7 @@ class AuthSettingsController extends Controller {
$token = $e->getToken();
}
if ($token->getUID() !== $this->uid) {
/* We have to throw the OC version so both OC and OCP catches catch it */
/** @psalm-suppress DeprecatedClass We have to throw the OC version so both OC and OCP catches catch it */
throw new OcInvalidTokenException('This token does not belong to you!');
}
return $token;

@ -33,7 +33,6 @@
namespace OC\Core\Controller;
use OC\Authentication\Events\AppPasswordCreatedEvent;
use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
@ -332,7 +331,7 @@ class ClientFlowLoginController extends Controller {
try {
$token = $this->tokenProvider->getToken($password);
if ($token->getLoginName() !== $user) {
throw new OcInvalidTokenException('login name does not match');
throw new InvalidTokenException('login name does not match');
}
} catch (InvalidTokenException $e) {
$response = new StandaloneTemplateResponse(

@ -27,7 +27,6 @@ declare(strict_types=1);
*/
namespace OC\Core\Controller;
use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException;
use OC\Core\Db\LoginFlowV2;
use OC\Core\Exception\LoginFlowV2NotFoundException;
use OC\Core\Service\LoginFlowV2Service;
@ -212,7 +211,7 @@ class ClientFlowLoginV2Controller extends Controller {
try {
$token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password);
if ($token->getLoginName() !== $user) {
throw new OcInvalidTokenException('login name does not match');
throw new InvalidTokenException('login name does not match');
}
} catch (InvalidTokenException $e) {
$response = new StandaloneTemplateResponse(

@ -29,10 +29,10 @@ declare(strict_types=1);
*/
namespace OC\Authentication\Token;
use OC\Authentication\Exceptions\ExpiredTokenException;
use OC\Authentication\Exceptions\InvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
use OC\Authentication\Exceptions\WipeTokenException;
use OCP\Authentication\Exceptions\ExpiredTokenException;
use OCP\Authentication\Exceptions\InvalidTokenException;
use OCP\Authentication\Exceptions\WipeTokenException;
interface IProvider {
/**

@ -29,9 +29,9 @@ namespace OC\Authentication\Token;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OC\Authentication\Exceptions\InvalidTokenException as OcInvalidTokenException;
use OC\Authentication\Exceptions\PasswordlessTokenException;
use OCP\Authentication\Exceptions\ExpiredTokenException;
use OCP\Authentication\Exceptions\InvalidTokenException;
use OCP\Authentication\Exceptions\PasswordlessTokenException;
use OCP\Authentication\Exceptions\WipeTokenException;
use OCP\Authentication\Token\IProvider as OCPIProvider;
@ -222,6 +222,7 @@ class Manager implements IProvider, OCPIProvider {
return $this->publicKeyTokenProvider->rotate($token, $oldTokenId, $newTokenId);
}
/** @psalm-suppress DeprecatedClass We have to throw the OC version so both OC and OCP catches catch it */
throw new OcInvalidTokenException();
}
@ -234,6 +235,7 @@ class Manager implements IProvider, OCPIProvider {
if ($token instanceof PublicKeyToken) {
return $this->publicKeyTokenProvider;
}
/** @psalm-suppress DeprecatedClass We have to throw the OC version so both OC and OCP catches catch it */
throw new OcInvalidTokenException();
}