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())) {
Comments
Comment #2
gugalamaciek commentedPatch for proposed resolution:
Comment #3
gugalamaciek commentedComment #4
danflanagan8I 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
mailgets added to theuserinfo_mappingsinopenid_connectandopenid_connect_user_properties_ignore_alteris being used to un-ignore themailproperty.I was actually surprised it took so much work to allow a user's email to update during login.
Comment #7
pfrillingI added tests validating the fix. Thanks for the patches!