Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
user.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Nov 2020 at 13:06 UTC
Updated:
23 Apr 2021 at 08:09 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
cilefen commentedThis is interesting, and in a way the opposite of #2267603: "Login" link shows up for logged-in users as well.
Comment #3
cilefen commentedWrong tag - sorry!
Comment #4
paulocsAttaching test only patch and a patch.
Tagging the Bug Smash Initiative to discussion.
Comment #5
paulocsComment #6
paulocsYes, I was working in the related issue as well, but I think the logout link and login link must have a different approach and that is why I opened na issue specifically for the logout link.
Comment #9
cilefen commentedThey are, let us say, thematically related but may have different causes.
Comment #10
paulocsProblem came after #2193803: Anonymous users receive access denied when attempting to logout was fixed.
Comment #11
chandrashekhar_srijan commentedPlease review. The solution is conflicting with https://www.drupal.org/project/drupal/issues/2193803.
Comment #12
chandrashekhar_srijan commentedComment #13
abh.ai commentedSeems like the patch on this comment fixes this issue as well: https://www.drupal.org/project/drupal/issues/2267603#comment-13893903
Comment #14
vakulrai commentedThe solution to add
_user_is_logged_in: 'TRUE'has an exception that it is redirecting the user to "Access denied" page which should not be the case , the anonymous user should get redirected to "Home page".The tests are failing because of that , so made some changes to the user subscriber and updated few tests.
Thanks.
Comment #15
vakulrai commentedFixed some Coding standard issues.
Comment #16
vikashsoni commentedApplied #15 patch working fine sharing screenshot...
Comment #17
guilhermevp commentedPatch #15 test is stuck.
Comment #18
sonam.chaturvedi commentedComment #19
sonam.chaturvedi commentedVerified and tested patch#15. Patch applied successfully.
Testing Steps:
1. Goto Structure > Menus > Main navigation
2. Create a link with title "Logout" and link "/user/logout"
3. Logout from the site
4. Check "Logout" link is displayed for anonymous user
5. Now apply the patch
6. Again, check "Logout" link is not displayed for anonymous user
7. Login to the site and check "Logout" link is displayed for authenticated user
Testing Results:
1. "Logout" link is not displayed for anonymous user
2. Authenticated user is directed to homepage on logging out.
Comment #20
sonam.chaturvedi commentedComment #21
adalbertov commentedJust checked the patch, it indeed works, but there is a CI error happening with the tests runs for patch #15. It could be something not related with issue in hand(like a SSH key error), but since it didn't perform correctly, I'm moving the issue to "Needs Work". If its not related, please disconsider this point, and keep moving the issue.
Comment #22
acbramley commentedThanks for the patch! I've slightly improved the asserts by using linkByHref(Not)Exists
Comment #23
Madhu kumar commentedPatch #22 applied cleanly and working as expected and sharing screenshot for reference.
Comment #24
Madhu kumar commentedComment #25
acbramley commentedOn further inspection I actually don't think this is right. This is effectively redirecting a user to the frontpage on any 403 that isn't the logout page which is a change in behaviour
Comment #26
acbramley commentedSorry it's this bit that's not right. It should be
||so we don't redirect if it's not a 403 OR it's not the user.logout route. I think it'd make more sense to invert the conditions and put the whole block inside it rather than the early return.Comment #27
acbramley commentedHere's an updated patch
Comment #28
acbramley commentedRemoves extra whitespace -_-
Comment #29
dwwThis looks great, thanks!
The test coverage seems pretty solid. I can't think of any aspect of this bug that isn't reflected in the new tests.
I only have 1 tiny ubernit that stopped me from RTBC'ing:
Could be:
// Create a user with the required permissions.(or just remove this comment entirely, the code is self-documenting enough).
Thanks again!
-Derek
Comment #30
dwwBah, this is trivial enough, I'm just gonna do it and self-RTBC... ;)
Comment #32
catchThis looks good, and the correct redirection fix for #2193803: Anonymous users receive access denied when attempting to logout which introduced the bug in the first place trying to fix a diferent one.
Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!