Problem/Motivation

There is a user setting named notify.cancel_confirm, which should be used a default value for "Account cancellation confirmation". Unfortunately it has no effect. Besides that you are not able to change this default setting in the account settings form (admin/config/people/accounts).

This is a follow up issue of https://www.drupal.org/project/drupal/issues/2854884.

Proposed resolution

  1. Use the user setting named notify.cancel_confirm as default value for the user cancel form.
  2. Provide a checkbox in account settings (admin/config/people/accounts) under "When cancelling a user account", with a note that this can be overridden by users with sufficient permissions.

Issue fork drupal-3028634

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

pminf created an issue. See original summary.

jepster_’s picture

There is a user setting named notify.cancel_confirm, which should be used a default value for "Account cancellation confirmation".

I am not sure about this. Because if I set notify.cancel_confirm to true, a confirmation email will be sent, when a user (not admin - just a user with permission to cancel his account) wants to cancel his account. If the value is false, the email won't be send. Tried this a few times.

So if notify.cancel_confirm is set to false I suggest: cancel the account directly. Because no email will be send. What do you think? Have you tried to set notify.cancel_confirm to true or false and cancel a user account on your end?

mmbk’s picture

I confirm pminf's problem (maybe it has to be refined),

* notify.cancel_confirm is set to false by administrator
* User cancels his account from /user/UID/edit
* redirects to /user/UID/cancel
* he has the options 'cancel account' and 'cancel'
* (The naming seems to be a bit confusing but this is not in the scope of this issue)
* He clicks 'cancel account'
* redirects to /user/UID
- the message "A confirmation request to cancel your account has been sent to your email address."
- but the notification mail is NOT send - as defined by the settings
- The account remains active - there is no posibility to realy cancel the account as the confirmation link can not be retrieved.

pminf’s picture

OK, so something is wrong here. In short: if you set notify.cancel_confirm in user.settings.yml to false, import the configuration and delete your own account, you wrongly get the message "A confirmation request to cancel your account has been sent to your email address.", an e-mail is not send and the account is not cancelled at all.

Note that if you cancel a account other then your own everything is fine.

jepster_’s picture

Thanks for confirming @mmbk and @pminf. So I suggest that we cancel the account immediately, if "notify.cancel_confirm" is set to false. Without sending a confirmation email. Also we should make this setting editable from admin backend via webbrowser. Do you agree? If so, we could start coding a patch here.

pminf’s picture

Status: Active » Needs review
StatusFileSize
new2.75 KB

Yes, I agree. Here is my first try to fix it. It provides the checkbox for the user account setting. Unfortunately the account is still not being cancelled. So it's not a complete patch but a start.

pminf’s picture

StatusFileSize
new2.99 KB

Sorry, my last patch contained wrong changes.

The last submitted patch, 6: user-cancel-confirm-3028634-6.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 7: user-cancel-confirm-3028634-7.patch, failed testing. View results

pminf’s picture

Assigned: pminf » Unassigned
jepster_’s picture

Status: Needs work » Needs review
StatusFileSize
new4.91 KB

Thanks for the patch with the form edit. No idea why Drupal\Tests\dblog\Functional\DbLogTest is failing here.

I have rerolled the patch and added changes. So the user account will be immediately canceled, if the cancel notify option has been disabled.

Also I have noticed, that the cancel notify option has not been working, if you have selected it as admin. Means that you can select a notify option, if you want to cancel a user account from the page at /admin/people. I have also made this option working and tried it a few times.

Please review. If the tests are failing: please assist in tests fixing.

Status: Needs review » Needs work

The last submitted patch, 11: 3028634-user-account-default-setting.patch, failed testing. View results

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

the_g_bomb’s picture

Now that the setting is being respected does that mean a default setting of true is being obeyed in the test?

Do the tests now need that setting asserted to make sure that drupal isn't waiting on a confirmation email to be sent.

$this->config('user.settings')->set('notify.cancel_confirm', FALSE)->save();

And we may perhaps need another failure test to check if the cancel_confirm is set to true that the user account isn't deleted automatically?

the_g_bomb’s picture

Status: Needs work » Needs review
StatusFileSize
new5.4 KB

I have rerolled the patch added in 11, but added the test assertion mentioned above into the tests
testUserCancelByAdmin() and testUserWithoutEmailCancelByAdmin()

Status: Needs review » Needs work

The last submitted patch, 15: cancel_confirm-default-setting-3028634-15.patch, failed testing. View results

the_g_bomb’s picture

Status: Needs work » Needs review
StatusFileSize
new7.82 KB

Missed a test, obviously

Status: Needs review » Needs work

The last submitted patch, 17: cancel_confirm-default-setting-3028634-16.patch, failed testing. View results

the_g_bomb’s picture

Extraneous dot!

the_g_bomb’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: cancel_confirm-default-setting-3028634-19.patch, failed testing. View results

the_g_bomb’s picture

Status: Needs work » Needs review
StatusFileSize
new8.17 KB

Last attempt at getting the tests working before someone else will need to have a look.

Slightly different attempt this time, rather than setting the default value using:
$this->config('user.settings')->set('notify.cancel_confirm', FALSE)->save();

I'm setting the cancel form field to FALSE.

If this doesn't work, hopefully someone else can take a look.

Status: Needs review » Needs work

The last submitted patch, 22: cancel_confirm-default-setting-3028634-22.patch, failed testing. View results

the_g_bomb’s picture

Status: Needs work » Needs review
StatusFileSize
new12.94 KB

OK, so I found some legitimate issues with the multipleCancelConfirm submit function and the issue doesn't look like it was just tests.

That being said I have updated the tests a bit as well, in case the default settings weren't set properly in the first place.

On cancel submission it is possible that if you give "Cancel own user account" to authenticated users, they could remove themselves and be redirected to 'collection', but that would be 404 for a deleted user, so I have added a redirect in there for those users too.

This will be my last attempt however.

Status: Needs review » Needs work

The last submitted patch, 24: cancel_confirm-default-setting-3028634-24.patch, failed testing. View results

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

julien’s picture

Slightly changes for 8.9.x to avoid Hunk succeeed as tests changes.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

nikitagupta’s picture

Status: Needs work » Needs review
StatusFileSize
new12.62 KB

Rerolled patch #28.

Status: Needs review » Needs work

The last submitted patch, 30: 3028634-30.patch, failed testing. View results

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new12.64 KB
new948 bytes

Handled one of the failures.

Status: Needs review » Needs work

The last submitted patch, 32: 3028634-32.patch, failed testing. View results

msuthars’s picture

Assigned: Unassigned » msuthars
msuthars’s picture

Assigned: msuthars » Unassigned
Status: Needs work » Needs review
StatusFileSize
new16.17 KB
new4.57 KB

Fixed the test case. Remove a assertions that is not working with current scenario. Added some assertions also in DbLogTest.

Status: Needs review » Needs work

The last submitted patch, 35: 3028634-35.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

orodicio’s picture

We are using the #32 one, because the last one, the #35 one include code that prevents the user from deleting it's own account.

+ // Prevent the account deletion for the current logged-in user.
+ if ($this->entity->id() != $this->currentUser()->id()) {
+ user_cancel($form_state->getValues(), $this->entity->id(), $form_state->getValue('user_cancel_method'));
$form_state->setRedirectUrl($this->entity->toUrl('collection'));

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

s.messaris’s picture

StatusFileSize
new2.54 KB

Here is a ptach compatible with 10.2.7

smustgrave’s picture

This came up as daily target for the #bugsmash initative.

Looking at the summary appears to be missing some sections, specifically what are the steps. Recommend using the standard issue template.

Also will need some kind of test coverage if a bug.

Also all fixes should be in MRs.

the_g_bomb’s picture

I think I remember that the current tests are falsely passing (without any patch). As I recall, it was a while ago, I think I found that there were tests scenarios that were never activated and as such the tests always just passed, but I could be wrong.

I think with this new setting I tried to update the tests, to check all the scenarios but found I couldn't get to the point where they could pass.

Hopefully #32 or #35 have improved that.

That latest patch doesn't include any test changes at all, I would ignore that and can only assume it is here to get the functionality added to a site without tests.

I will try to take another look.

the_g_bomb’s picture

As this issue was raised as a follow up to #2854884: Not able to disable account cancel confirm e-mail, which looks like it was fixed in #2854252: User forms broken for admin without 'administer users'. Hopefully the original tests were fixed there too.

This issue provides a form that allows the default setting to be changed and used if it is set.

We will need to check how the changes to the original issue has affected the tests and if they need to be updated to use the default settings.

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

mdranove’s picture

Status: Needs work » Needs review
mdranove’s picture

Status: Needs review » Needs work

Added a new test, but need to fixup old tests too.

mdranove’s picture

Status: Needs work » Needs review
the_g_bomb’s picture

Status: Needs review » Needs work

I think there is some work required in core/modules/user/src/Form/UserMultipleCancelConfirm.php as well.

mdranove’s picture

Status: Needs work » Needs review
mdranove’s picture

Status: Needs review » Needs work
mdranove’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Left comments on the MR. Seems to contain a number of out of scope changes. If they're all needed to get the tests to just pass then something is probably missing.

But new config key will need a schema + upgrade path.

Issue summary still needs some attention.

mdranove changed the visibility of the branch 11.x to hidden.

oily’s picture

I added thread to the usercancelTest.php. There is a function that makes PHPSTAN fail as it doesnt exist.

mdranove’s picture

Status: Needs work » Needs review

Took another look on a new branch. Should be good now.

oily’s picture

@mdranove You may have had a particular reason? but normally it's best to stick to one branch per issue. Anyway checking your latest changes.

smustgrave’s picture

Still appears to be missing default config, schema, and post update.
Update

Also with the fix being in user module that’s probably where test coverage should be.

oily’s picture

@mdranove Just ran the test-only test (you have to run it manually). It is passing but it should fail. What that normally means is the test coverage is passing before and after the code fixes in the MR are applied. That is not happening. Changing to 'needs work'.

oily’s picture

Status: Needs review » Needs work
oily’s picture

@mdranove I see the test-only test is now failing and only one other test is failing. Worth re-running. For #63 hopefully the test code that seems to work can be moved/ refactored into the user module.

oily’s picture

Re: #63 There are two tests in the user module.
Re: #66 The thread has been resolved. Test coverage seems also ready for review. Back to 'Needs review.'

oily’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Also summary is still incomplete.

smustgrave’s picture

Also think we need to think this one through a little now that I'm looking more closely

'When enabled, the user must confirm the account cancellation via email.'),

While this does set the checkbox to TRUE the person can still uncheck it.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.