Inherit private Exception from OCP to fix class hierarchy#42577
Closed
Inherit private Exception from OCP to fix class hierarchy#42577
Conversation
Fix regression of authentication workflow because class hierarchy changed when moving Exception to OCP Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
And always throw OC versions for BC Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
| if ($token->getUID() !== $this->uid) { | ||
| throw new InvalidTokenException('This token does not belong to you!'); | ||
| /* 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!'); |
Check notice
Code scanning / Psalm
DeprecatedClass
| $token = $this->tokenProvider->getToken($password); | ||
| if ($token->getLoginName() !== $user) { | ||
| throw new InvalidTokenException('login name does not match'); | ||
| throw new OcInvalidTokenException('login name does not match'); |
Check notice
Code scanning / Psalm
DeprecatedClass
| $token = \OC::$server->get(\OC\Authentication\Token\IProvider::class)->getToken($password); | ||
| if ($token->getLoginName() !== $user) { | ||
| throw new InvalidTokenException('login name does not match'); | ||
| throw new OcInvalidTokenException('login name does not match'); |
Check notice
Code scanning / Psalm
DeprecatedClass
This was referenced Jan 4, 2024
nickvergessen
requested changes
Jan 10, 2024
Member
nickvergessen
left a comment
There was a problem hiding this comment.
Blocking this as I prefer #42640
Contributor
Author
|
Replaced by #42640 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix regression of authentication workflow because class hierarchy changed when moving Exception to OCP
Summary
27:
graph BT; \OC\ExpiredTokenException --> \OC\InvalidTokenException \OC\WipeTokenException --> \OC\InvalidTokenException \OC\InvalidTokenException --> \Exception28:
graph BT; \OC\ExpiredTokenException --> \OCP\ExpiredTokenException \OC\WipeTokenException --> \OCP\WipeTokenException \OC\InvalidTokenException --> \OCP\InvalidTokenException \OCP\ExpiredTokenException --> \OCP\InvalidTokenException \OCP\WipeTokenException --> \OCP\InvalidTokenException \OCP\InvalidTokenException --> \ExceptionThis PR:
graph BT; \OC\ExpiredTokenException --> \OCP\ExpiredTokenException \OC\WipeTokenException --> \OCP\WipeTokenException \OC\InvalidTokenException --> \OCP\InvalidTokenException \OCP\ExpiredTokenException --> \OC\InvalidTokenException \OCP\WipeTokenException --> \OC\InvalidTokenException \OCP\InvalidTokenException --> \ExceptionIt is a bit sad to reference
OCfromOCPbut I am not sure we have a better solution here to restore backward compatibility of the API. We should still move all code to using theOCPnamespaced exceptions and remove theOCones when possible.Checklist