Problem/Motivation

After upgrading from 8.x-1.6 to 2.1.0 there is now a 'Logout all other devices' toggle on the register page.

This obviously doesn't make sense since users who are registering would not be logged in anywhere.

This also throws an error in the Drupal logs whenever the register page is visited.

Warning: Undefined array key "pass" in persistent_login_form_user_form_alter() (line 63 of /home/XXX/XXX/web/modules/contrib/persistent_login/persistent_login.module)

Steps to reproduce

1. Install PL 2.1.0 and enable.
2. Visit the register page as a logged out user.

Comments

jabeler created an issue. See original summary.

gapple’s picture

I wasn't able to reproduce this on a standard install, are there other modules you're using that affect user accounts or registration?

There is already a check that the form is only altered when it's for an existing registered user:

  $user = $form_state->getFormObject()->getEntity();
  if (!$user || $user->isAnonymous()) {
    return;
  }

An additional check could be that the 'pass' form element exists, in case another module is breaking the existing expectation, but I don't want to preemptively mask over an underlying issue and make a fix to the root cause more difficult.

mr.white’s picture

Thanks for looking into this.

I haven’t had a chance to test of a fresh install, but this is the list of modules from composer. The actual installed versions are the most current.

I thought the items in bold may be affecting the login/registration flow, so I tested with those disabled but that didn’t seem to have an effect on the registration page toggle. I haven’t had a chance to do further elimination tests yet.

"composer/installers": "^2.0",
"cweagans/composer-patches": "^1.7",
"defuse/php-encryption": "^2.3",
"drupal/add_to_head": "^1.0@beta",
"drupal/admin_toolbar": "^3.4",
"drupal/advagg": "^6.0@alpha",
"drupal/aggregator": "^2.0",
"drupal/backup_migrate": "^5.0",
"drupal/backup_migrate_aws_s3": "^5.0",
"drupal/block_classes": "^1.0",
"drupal/captcha": "^2.0@beta",
"drupal/cloudflare": "^2.0@alpha",
"drupal/coffee": "^1.3",
"drupal/core-composer-scaffold": "^10.0",
"drupal/core-recommended": "^10.0",
"drupal/discourse_sso": "^2.0@RC",
"drupal/dxpr_theme": "^5.1",
"drupal/extlink": "^1.7",
"drupal/field_group": "^3.4",
"drupal/flood_control": "2.3.x-dev@dev",
"drupal/fontawesome": "^2.25",
"drupal/gin": "^3.0@RC",
"drupal/gin_login": "^2.0",
"drupal/honeypot": "2.1.x-dev@dev",

"drupal/login_emailusername": "^2.1",
"drupal/mailsystem": "^4.4",
"drupal/masquerade": "^2.0@RC",
"drupal/menu_items_visibility": "^1.1",
"drupal/metatag": "^2.0",
"drupal/pathauto": "^1.11",
"drupal/persistent_login": "^2.1",
"drupal/phpmailer_smtp": "^2.2",
"drupal/purge": "^3.4",
"drupal/r4032login": "^2.2",
"drupal/recaptcha": "^3.1",
"drupal/recaptcha_v3": "^2.0@alpha",

"drupal/redirect": "^1.8",
"drupal/rules": "3.x-dev@dev",
"drupal/schema_metatag": "^3.0",
"drupal/simple_sitemap": "^4.1",
"drupal/username_validation": "^1.2",
"drupal/views_bulk_operations": "^4.2",
"drupal/views_data_export": "^1.3",
"drupal/zendesk": "^3.0.0-alpha7”

rmasoad@gmail.com’s picture

StatusFileSize
new584 bytes

Check for Anonymous user is not correct, here is a patch to fix it.

gapple’s picture

It looks like #3311563: Safeguarding against UnblockUser::execute()'s method unblocking the anonymous user introduced strict checks in isAnonymous() for 10.1, so that it no longer returns true if the entity id is null (as it did in 10.0 and prior). Rather than empty($user->id(), I think the appropriate additional check is isNew().

(Adding a check on the 'pass' field wouldn't work, since depending on the "Require email verification when a visitor creates an account" configuration option the pass field may be present on the register form)

  • gapple committed eb1398e6 on 2.x
    Issue #3376641: Fix Logout All Devices added to register form
    
gapple’s picture

Status: Active » Fixed
mr.white’s picture

Confirmed 2.1.1 working perfectly on Drupal 10.1.2.

Thx!

Status: Fixed » Closed (fixed)

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