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

  1. Create a MR with updated description
  2. Add a test (?)
  3. Review
  4. Commit!

User interface changes

Before:

After:

Issue fork drupal-3469116

Command icon 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

MrDaleSmith created an issue. See original summary.

Prashant.c made their first commit to this issue’s fork.

prashant.c’s picture

StatusFileSize
new29.62 KB

I 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.

prashant.c’s picture

Version: 10.3.x-dev » 11.0.x-dev

Prashant.c changed the visibility of the branch 3469116-new-user-logout to hidden.

prashant.c’s picture

Status: Active » Needs review
prashant.c’s picture

Tests are failing because the getDescription() {} method is expecting a translatable string, which in case we have to provide. Looking for input here.

smustgrave’s picture

Version: 11.0.x-dev » 11.x-dev
Status: Needs review » Needs work
Issue tags: +Needs title update, +Needs tests

This 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.

prashant.c’s picture

Title: New User Logout confirm Form is misleading » Logout confirmation form shows inappropriate confirmation description

Before adding tests we need to decide on what would be the "description" for this as requested in #8

sahana _n made their first commit to this issue’s fork.

sahana _n’s picture

Status: Needs work » Needs review
StatusFileSize
new264.17 KB
new103.42 KB

Hi Prashant.c

I created an MR Please review it.
If there are any inaccuracies, I would greatly appreciate your suggestions for improvement.

Thank you!!

prashant.c’s picture

Status: Needs review » Needs work

@sahana _n

Thanks for your efforts but in the existing MR we are already using the getDescription() {}new MR was not required. Please see #8

prashant.c changed the visibility of the branch 3469116-Logout-confirmation-form-shows-inappropriate-confirmation-description to hidden.

prashant.c’s picture

Issue tags: -Needs title update

@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.

prashant.c’s picture

TBD. Suggesting a couple of descriptions we can use:

  • Logging out will end your current session, and you will need to log in again to continue.
  • Once you log out, you’ll need to sign in again to access your account.
mrdalesmith’s picture

I like the second option, for brevity.

sahana _n’s picture

Status: Needs work » Needs review
StatusFileSize
new102.55 KB

Hi,

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!!

pameeela’s picture

Issue summary: View changes
StatusFileSize
new29.47 KB

Just 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!

prashant.c’s picture

@pameeela wrong screenshot attached :). Without description is good but see #8, we have to provide the description.

pameeela’s picture

Issue summary: View changes
StatusFileSize
new31.12 KB

Oops! 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.

pameeela’s picture

Issue summary: View changes
prashant.c’s picture

Yes, and this is added in #19

pameeela’s picture

Yes, I know that :)

I have made a minor change to the wording for review.

prashant.c’s picture

Looks good to me. In my opinion, we can move it to RTBC.

pameeela’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new32.37 KB

Updated screenshot. Still needs a test.

prashant.c’s picture

Status: Needs work » Needs review

Added the check to test the existence of the description and that should be sufficient I guess.

dishakatariya’s picture

Hi, 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!

omkar-pd’s picture

Status: Needs review » Needs work

Tests Failed.

pameeela’s picture

Hi @dishakatariya we already have screenshots for this so we don't need any new ones.

prashant.c’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Thanks, @pameeela for the rebase, pipelines passed, moving to NR.

smustgrave’s picture

Issue tags: +Needs usability review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.07 KB

The 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.

needs-review-queue-bot’s picture

Status: Needs work » Needs review

False positive

sagarmohite0031’s picture

StatusFileSize
new56.44 KB
new53.98 KB

Hello,
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-

b_sharpe’s picture

Status: Needs review » Reviewed & tested by the community

Everything 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.

nod_’s picture

Status: Reviewed & tested by the community » Needs work

Text needs some fixing, "you'll" should be replaced with "you will"

kostask made their first commit to this issue’s fork.

kostask’s picture

Status: Needs work » Needs review
sagarmohite0031’s picture

StatusFileSize
new54.05 KB
new61.85 KB

Hello,
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 -

yasminorj’s picture

StatusFileSize
new33.61 KB

Hi, 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.

messageLogout

benjifisher’s picture

Status: Needs review » Needs work

Usability 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.

benjifisher’s picture

From Comment #20:

Just 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 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):

  public function getDescription() {
    return '';
  }

The same day, the author of the commit made this comment #144538-186: User logout is vulnerable to CSRF:

I pushed a change to add some typehint returns. If we aren’t adding a description I removed that function.

Actually found an issue that return ’’ doesn’t match the docs of the inherited docs.

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 a TranslatableMarkup object, not a string. But it can return the object equivalent to an empty string:

  public function getDescription() {
    return $this->t('');
  }
kostask’s picture

Status: Needs work » Needs review
idebr’s picture

Status: Needs review » Needs work
Issue tags: -Needs usability review

phpcs fails in the MR

benjifisher’s picture

Status: Needs work » Needs review
Issue tags: +Needs issue summary update

It 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.

benjifisher’s picture

Well, 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.

kostask’s picture

Benji, 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.

benjifisher’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update
StatusFileSize
new60.78 KB

I 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.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I 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.

shalini_jha’s picture

I have been able to replicate and review all the comments. I am working on the test.

shalini_jha’s picture

Status: Needs work » Needs review

I have added test coverage for this, following the approach mentioned in #48. Moving this to NR for review. Kindly review the changes.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community

@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.

kristiaanvandeneynde’s picture

Issue tags: -Needs tests

Just 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!

  • catch committed 6e7b7926 on 10.5.x
    Issue #3469116 by prashant.c, pameeela, kostask, shalini_jha,...

  • catch committed ea33cc21 on 11.x
    Issue #3469116 by prashant.c, pameeela, kostask, shalini_jha,...

  • catch committed 6a073e8c on 11.1.x
    Issue #3469116 by prashant.c, pameeela, kostask, shalini_jha,...
catch’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x then cherry-picked to 11.1.x and 10.5.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.