Problem/Motivation
#144538 added a confirm form to the user logout process that is used in certain circumstances. This form uses the base class' getDescription() method, which populates the form with the default warning "This action cannot be undone". This is inappropriate for the process of logging out, which is not a destructive action.
Steps to reproduce
As a logged in user, directly visit user/logout on a site (to trigger the CSRF protection and use the confirm form). The misleading text will be visible above the confirm/cancel buttons.
Proposed resolution
Override the description in the new confirm form to contain empty text.
Remaining tasks
Create a MR with updated description- Add a test (?)
Review- Commit!
User interface changes
Before:

After:

| Comment | File | Size | Author |
|---|---|---|---|
| #50 | logout-confirm.png | 60.78 KB | benjifisher |
| #42 | messageLogoutWorking.png | 33.61 KB | yasminorj |
| #41 | Before layout new.png | 61.85 KB | sagarmohite0031 |
| #41 | After Layout new.png | 54.05 KB | sagarmohite0031 |
| #36 | Confirmation-Before.png.png | 53.98 KB | sagarmohite0031 |
Issue fork drupal-3469116
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
prashant.cI agree with this, this message is kind of irrelevant here because we already have in bolds
Are you sure you want to log out?and this is not something that cannot be undone, the user can always log in again.I would say a better thing would be to just not have this description at all.
Comment #4
prashant.cComment #7
prashant.cIn the original issue also the description is not shown https://www.drupal.org/files/issues/2024-03-26/Screenshot%202024-03-26%2....
Comment #8
prashant.cTests are failing because the
getDescription() {}method is expecting a translatable string, which in case we have to provide. Looking for input here.Comment #9
smustgrave commentedThis will need a title update as just the word "misleading" is vague and not sure what the problem is.
Probably should have test coverage as well.
Comment #10
prashant.cBefore adding tests we need to decide on what would be the "description" for this as requested in #8
Comment #13
sahana _n commentedHi Prashant.c
I created an MR Please review it.
If there are any inaccuracies, I would greatly appreciate your suggestions for improvement.
Thank you!!
Comment #14
prashant.c@sahana _n
Thanks for your efforts but in the existing MR we are already using the
getDescription() {}new MR was not required. Please see #8Comment #16
prashant.c@smustgrave The Title of the issue has already been updated removing the tag. Please re-add if you still see some issues with the current title.
Comment #17
prashant.cTBD. Suggesting a couple of descriptions we can use:
Comment #18
mrdalesmith commentedI like the second option, for brevity.
Comment #19
sahana _n commentedHi,
Even I liked the second option and I updated the MR Please review.
I verified that in Drupal version 11.x.
I would greatly appreciate your suggestions for improvement. Please let me know.
Thank you!!
Comment #20
pameeela commentedJust wanted to confirm this one because as noted above, this text wasn't there when the change was committed. Added a screenshot to the IS.
I also agree that it's better without a description, I think at this point logging out is pretty self explanatory!
Comment #21
prashant.c@pameeela wrong screenshot attached :). Without description is good but see #8, we have to provide the description.
Comment #22
pameeela commentedOops! Fixed.
I realise that the tests failed without a description, but that doesn't mean it's not possible :)
I guess it is better to update it to something more accurate for now than to have it be confusing.
Comment #23
pameeela commentedComment #24
prashant.cYes, and this is added in #19

Comment #25
pameeela commentedYes, I know that :)
I have made a minor change to the wording for review.
Comment #26
prashant.cLooks good to me. In my opinion, we can move it to RTBC.
Comment #27
pameeela commentedUpdated screenshot. Still needs a test.
Comment #28
prashant.cAdded the check to test the existence of the description and that should be sufficient I guess.
Comment #29
dishakatariya commentedHi, I have verified this issue in our D11 version with the latest MR- 3469116-11.x-new-user-logout and it applies cleanly. This isssue is resolved now.
Testing steps:
As a logged in user, directly visit user/logout on a site (to trigger the CSRF protection and use the confirm form). The misleading text will be visible above the confirm/cancel buttons.
Test Results:
Logout confirmation form shows the appropriate confirmation description now.
Adding before and after screenshots.
Still keeping this issue in needs review for the further code reviews.
Thanks!
Comment #30
omkar-pd commentedTests Failed.
Comment #31
pameeela commentedHi @dishakatariya we already have screenshots for this so we don't need any new ones.
Comment #32
prashant.cThanks, @pameeela for the rebase, pipelines passed, moving to NR.
Comment #33
smustgrave commentedComment #34
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #35
needs-review-queue-bot commentedFalse positive
Comment #36
sagarmohite0031 commentedHello,
I have verified this issue on D11 version.
MR applies cleanly.
Testing steps:
As a logged in user, directly visit user/logout on a site (to trigger the CSRF protection and use the confirm form).
The misleading text will be visible above the confirm/cancel buttons.
Test Results:
Logout confirmation form shows the appropriate confirmation description now.
Refer screenshots-
Comment #37
b_sharpe commentedEverything looks good, I'm sure the messaging will always be of debate, but this could always turn to a config option at a later date.
Comment #38
nod_Text needs some fixing, "you'll" should be replaced with "you will"
Comment #40
kostask commentedComment #41
sagarmohite0031 commentedHello,
I have verified this issue on D11 version.
MR applies cleanly.
Testing steps:
As a logged in user, directly visit user/logout on a site.
The misleading text will be visible above the confirm/cancel buttons.
Test Results:
Logout confirmation form shows the appropriate confirmation description.
Refer attachments -
Comment #42
yasminorj commentedHi, I've reviewed the code from branch 3469116-11.x-new-user-logout, and it works for me. I have attached a screenshot as evidence that it is working.
Comment #43
benjifisherUsability review
We discussed this issue at #3485024: Drupal Usability Meeting 2024-11-08. That issue will have a link to a recording of the meeting.
For the record, the attendees at the usability meeting were @benjifisher, @rkoller, and @simohell.
Our recommendation is to remove the text, "This action cannot be undone". Do not replace it with anything. The purpose of the form is clear without this additional text.
In other words, we strongly agree with Comment #3. And Comment #20.
I will add a separate comment with some technical notes.
If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.
Comment #44
benjifisherFrom Comment #20:
I tested by checking out Commit 62c4d2d2fa6 (the commit for #144538: User logout is vulnerable to CSRF on the 10.3.x branch). I installed Drupal with the Standard profile and visited
/user/logout/confirm. The text was there: "This action cannot be undone." It is true that the screenshot on #144538 does not show that text, but the text was there when the issue was committed.I was curious, so I investigated.
The problem is this commit on the MR for #144538: b6134f16, which removed this function (and added return-type declarations to 5 other functions):
The same day, the author of the commit made this comment #144538-186: User logout is vulnerable to CSRF:
That is a mistake. The text, "This action cannot be undone", comes from the base class. Removing that function means we are not overriding the base class.
Later that day (Comment #188), the author of the commit (and Comment #186) marked the issue RTBC. It is not good practice to review your own work.
The second line of Comment #186 makes the same observation as Comment #8 on this issue. Because the form class implements an interface,
getDescription()has to return aTranslatableMarkupobject, not a string. But it can return the object equivalent to an empty string:Comment #45
kostask commentedComment #46
idebr commentedphpcs fails in the MR
Comment #47
benjifisherIt is usually a bad idea to suppress phpcs warnings, but I think it is the right thing to do in this case.
There is a failure in
Drupal\Tests\layout_builder\Functional\LayoutBuilderBlocksTest::testBlockPlaceholder. That test is already listed on #2829040: [meta] Known intermittent, random, and environment-specific test failures, so I am re-running the tests. (I do not see a way to re-run a single test suite, so I am re-running the entire pipeline.)I have not tested, but the code change looks correct. I am setting the status to NR for testing and further review.
Comment #9 asked for automated tests, but I am not sure that is needed.
The issue summary needs an update (proposed resolution and screenshots), so I am adding the tag for that.
Comment #48
benjifisherWell, I tried to re-run the pipeline. I am not sure it is working.
If we do want automated tests, then we could test that the default text, "This action cannot be undone", does not appear on the page.
Comment #49
kostask commentedBenji, I agree that it is usually a bad idea to suppress phpcs warnings, but in this case there are valid reasons to do it.
I re-run the tests and now they are green.
Comment #50
benjifisherI am replacing the screenshot in the issue summary and rearranging a bit to match the usual template. (Screenshots go under "User interface changes".) I am replacing "more appropriate text" with "empty text" in the Proposed resolution section.
My screenshot looks a lot like the one in #144538: User logout is vulnerable to CSRF.
Previous comments and the Remaining tasks suggest adding an automated test, but I do not think that is needed.
Code looks good, the confirm form is what I show in the screenshot, and the confirm form works. RTBC.
Comment #51
quietone commentedI read the comments and the MR. All questions have been answered and this look fine. However, there is a question about a test, asked for in #9 and #27 but the tags, 'needs tests' was removed in #32 without comment. So, the question about a test needs to be answered.
I do think that this should have a test to prevent the re-introduction of a description on the form.
Comment #52
shalini_jha commentedI have been able to replicate and review all the comments. I am working on the test.
Comment #53
shalini_jha commentedI have added test coverage for this, following the approach mentioned in #48. Moving this to NR for review. Kindly review the changes.
Comment #54
benjifisher@shalini_jha: Thanks for adding the test coverage.
I reviewed the test. I think a single assertion is enough to avoid a regression.
The test passes on the feature branch, and the new assertion fails if I revert the non-test changes.
Back to RTBC.
Comment #55
kristiaanvandeneyndeJust reviewed as a subsystem maintainer, looks good to me. I also strongly agree with leaving out the description rather than adding something that states the obvious. Thanks everyone!
Comment #59
catchCommitted/pushed to 11.x then cherry-picked to 11.1.x and 10.5.x, thanks!