diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-05-27 09:21:47 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-05-27 09:21:47 +0200 |
commit | 2006a6dd0e568998965246263b142613660c5baf (patch) | |
tree | 2e1b640361f25e56bb4d244cc1fc57988224a918 /lib/private/Authentication/Token/DefaultTokenProvider.php | |
parent | b9d17cfdecd57a877ab2e5ecddee43ea48edc67f (diff) | |
download | nextcloud-server-2006a6dd0e568998965246263b142613660c5baf.tar.gz nextcloud-server-2006a6dd0e568998965246263b142613660c5baf.zip |
Improve traces of invalid token exceptions
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Authentication/Token/DefaultTokenProvider.php')
-rw-r--r-- | lib/private/Authentication/Token/DefaultTokenProvider.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/private/Authentication/Token/DefaultTokenProvider.php b/lib/private/Authentication/Token/DefaultTokenProvider.php index 3556cfd24b0..ee8a28d3cb0 100644 --- a/lib/private/Authentication/Token/DefaultTokenProvider.php +++ b/lib/private/Authentication/Token/DefaultTokenProvider.php @@ -117,7 +117,7 @@ class DefaultTokenProvider implements IProvider { */ public function updateToken(IToken $token) { if (!($token instanceof DefaultToken)) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Invalid token type"); } $this->mapper->update($token); } @@ -130,7 +130,7 @@ class DefaultTokenProvider implements IProvider { */ public function updateTokenActivity(IToken $token) { if (!($token instanceof DefaultToken)) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Invalid token type"); } /** @var DefaultToken $token */ $now = $this->time->getTime(); @@ -157,7 +157,7 @@ class DefaultTokenProvider implements IProvider { try { $token = $this->mapper->getToken($this->hashToken($tokenId)); } catch (DoesNotExistException $ex) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Token does not exist", 0, $ex); } if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) { @@ -179,7 +179,7 @@ class DefaultTokenProvider implements IProvider { try { $token = $this->mapper->getTokenById($tokenId); } catch (DoesNotExistException $ex) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Token with ID $tokenId does not exist", 0, $ex); } if ((int)$token->getExpires() !== 0 && $token->getExpires() < $this->time->getTime()) { @@ -241,7 +241,7 @@ class DefaultTokenProvider implements IProvider { */ public function setPassword(IToken $token, string $tokenId, string $password) { if (!($token instanceof DefaultToken)) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Invalid token type"); } /** @var DefaultToken $token */ $token->setPassword($this->encryptPassword($password, $tokenId)); @@ -334,13 +334,13 @@ class DefaultTokenProvider implements IProvider { } catch (Exception $ex) { // Delete the invalid token $this->invalidateToken($token); - throw new InvalidTokenException(); + throw new InvalidTokenException("Can not decrypt token password: " . $ex->getMessage(), 0, $ex); } } public function markPasswordInvalid(IToken $token, string $tokenId) { if (!($token instanceof DefaultToken)) { - throw new InvalidTokenException(); + throw new InvalidTokenException("Invalid token type"); } //No need to mark as invalid. We just invalide default tokens |