function hook_simplesamlphp_auth_user_attributes in simpleSAMLphp Authentication 8.3
Hook to alter a Drupal user account after SAML authentication.
Allows other modules to change fields or properties on the Drupal account after a user logged in through SimpleSAMLphp. This can be used to add map additional SAML attributes to Drupal user profile fields.
Parameters
\Drupal\user\UserInterface $account: The Drupal account that can be altered.
array $attributes: The SimpleSAMLphp attributes for this user.
Return value
\Drupal\user\UserInterface|bool The altered Drupal account or FALSE if nothing was changed.
1 invocation of hook_simplesamlphp_auth_user_attributes()
- SimplesamlExternalauthSubscriber::externalauthLogin in src/
EventSubscriber/ SimplesamlExternalauthSubscriber.php - React on an ExternalAuth login event.
File
- ./
simplesamlphp_auth.api.php, line 130 - Hooks for simpleSAMLphp Authentication module.
Code
function hook_simplesamlphp_auth_user_attributes(\Drupal\user\UserInterface $account, $attributes) {
$saml_first_name = $attributes['first_name'];
if ($saml_first_name) {
$account
->set('field_first_name', $saml_first_name);
return $account;
}
return FALSE;
}