Error on OpenIDConnect::saveUserinfo() when trying use account loaded by email

Created on 8 November 2023, about 1 year ago
Updated 2 July 2024, 6 months ago

Problem/Motivation

When I'm trying to login, I receive this error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function id() on array in Drupal\openid_connect\OpenIDConnect->saveUserinfo() (line 696 of modules/contrib/openid_connect/src/OpenIDConnect.php).

Steps to reproduce

Proposed resolution

Current implementation:

$account_by_mail = $this->userStorage->loadByProperties(['mail' => $claim_value]);
if (empty($account_by_mail) || ($account_by_mail->id() == $account->id())) {

Proposed improvement (use current() in second if condition):

$account_by_mail = $this->userStorage->loadByProperties(['mail' => $claim_value]);
if (empty($account_by_mail) || (current($account_by_mail)->id() == $account->id())) {
πŸ› Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

πŸ‡΅πŸ‡±Poland gugalamaciek

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @gugalamaciek
  • πŸ‡΅πŸ‡±Poland gugalamaciek

    Patch for proposed resolution:

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.4 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    100 pass
  • Status changed to RTBC 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

    I ran into this exact problem. The patch looks fine and fixed my problem. It would be awesome to have test coverage, but there's not a ton of test coverage in the module to begin with. I don't see any existing test that would be easy to modify or copy/paste. So let's just RTBC this as is.

    In case it's not clear from the IS, this is triggered when mail gets added to the userinfo_mappings in openid_connect and openid_connect_user_properties_ignore_alter is being used to un-ignore the mail property.

    I was actually surprised it took so much work to allow a user's email to update during login.

Production build 0.71.5 2024