The data that was being saved on the config settings for 'no_account_authenticated_user_account' was the User ID so we should change the code from user_load_by_name to user_load;

<?php
-    $user = user_load_by_name($config->get('no_account_authenticated_user_account'));
+    $user = user_load($config->get('no_account_authenticated_user_account'));
?>

I have also modified the error message if the $user is empty:

<?php
-      \Drupal::messenger()->addError(t('You have been authenticated but there is now account matching your access and now default role has been provided. Please contact a site administrator.'));
+      \Drupal::messenger()->addError(t('You have been authenticated but there is no account available for you to continue logging in. Please contact a site administrator.'));
?>

The logger also tries to pull an empty $user object so I removed it.

<?php
       \Drupal::logger('saml_sp')->notice('User authenticated via %idp_label with email %mail, cannot grant access to generic account as the generic account could not be loaded.', [
         '%idp_label' => $idp->label(),
         '%mail' => $email,
        '%name' => $user->getAccountName(),
?>

Attached is the patch I made.

Issue fork saml_sp-3175114

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

mjgruta created an issue. See original summary.

mjgruta’s picture

StatusFileSize
new1.5 KB

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

jrglasgow’s picture

Status: Active » Fixed

user_load is deprecated, I changes to Drupal\user\Entity\User::load()

merged

Status: Fixed » Closed (fixed)

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