-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Redirect guests to login if they follow the link of a comment mention… #11185
Redirect guests to login if they follow the link of a comment mention… #11185
Conversation
* @NoCSRFRequired | ||
* | ||
* @param string $id the comment ID | ||
* @return Response | ||
*/ | ||
public function view($id) { | ||
$currentUser = $this->userSession->getUser(); | ||
if (!$currentUser instanceof IUser) { | ||
return new RedirectResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a bit of a hack. Would be more comfortable if that was dealt with on the middleware-level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fine by me. The middleware would basically do the same. Just instead of throwing an exception it makes a redirect response...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but then we have it at one, reusable place, don't need to soften the restrictions of the controller and are less likely to refactor it away accidentally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still prefer this to be backported to 14 instead of a middleware change.
Also for the middleware, the constructor still needs to be changed to get rid of Folder
I think, but we could test that later.
The other thing I'm not sure about is, if we should do that for all pages which are not PublicPage
or if it should be explicit, because it makes no sense to do this for API calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
If we can avoid another annotation we should go for it… I share your doubts about it, too. Thus tending towards an explicit statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why isn't the default logic kicking in (to redirect if not logged in)?
Anyway lets do this as it is a bit specific to comments anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed
…-notification Signed-off-by: Joas Schilling <[email protected]>
dfb0ff0
to
e375107
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased to run the tests again lets see :)
…-notification
Fix #11184