Commit 92a48a4c authored by João Ventura's avatar João Ventura Committed by João Ventura
Browse files

Issue #2989261 by gugalamaciek, Leksat, sun, jcnventura, Mario Steinitz,...

Issue #2989261 by gugalamaciek, Leksat, sun, jcnventura, Mario Steinitz, PCate: Claim mapping for 'email' results in error "property type not implemented: 'email'"
parent 90a44435
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -670,6 +670,25 @@ class OpenIDConnect {
                $account->set($property_name, ['target_id' => $file->id()]);
                break;

              case 'email':
                if ($property_name === 'mail') {
                  // The account email address is a very special user property,
                  // as it is one of the properties that requires to be unique
                  // for all Drupal users.
                  $account_by_mail = $this->userStorage->loadByProperties(['mail' => $claim_value]);
                  if (empty($account_by_mail) || ($account_by_mail->id() == $account->id())) {
                    $account->set('mail', $claim_value);
                  }
                  else {
                    $this->logger->warning('Could not save user info. Email address %email is already used in another account.',
                      ['%email' => $claim_value]);
                  }
                }
                else {
                  $account->set($property_name, $claim_value);
                }
                break;

              default:
                $this->logger->error('Could not save user info, property type not implemented: %property_type',
                  ['%property_type' => $property_type]