Commit 08b87c50 authored by jcnventura's avatar jcnventura Committed by Joao Ventura
Browse files

Issue #2912214 by jcnventura: Restore deprecated hook_openid_connect_save_userinfo()

parent 93d0fdfa
......@@ -262,6 +262,35 @@ function hook_openid_connect_userinfo_save(UserInterface $account, array $contex
}
}
/**
* Save userinfo hook.
*
* This hook runs after the claim mappings have been applied by the OpenID
* Connect module, but before the account will be saved.
*
* A popular use case for this hook is mapping additional information like
* user roles or other complex claims provided by the identity provider, that
* the OpenID Connect module has no mapping mechanisms for.
*
* @param \Drupal\user\UserInterface $account
* A user account object.
* @param array $context
* An associative array with context information:
* - tokens: Array of original tokens.
* - user_data: Array of user and session data from the ID token.
* - userinfo: Array of user information from the userinfo endpoint.
* - plugin_id: The plugin identifier.
* - sub: The remote user identifier.
* - is_new: Whether the account was created during authorization.
*
* @ingroup openid_connect_api
* @deprecated in openid_connect:8.x-1.0-beta6 and is removed from openid_connect:8.x-2.0.
* Use hook_openid_connect_userinfo_save() instead.
* @see https://www.drupal.org/project/openid_connect/issues/2912214
*/
function hook_openid_connect_save_userinfo(UserInterface $account, array $context) {
}
/**
* Alter hook to alter the user properties to be skipped for mapping.
*
......
......@@ -181,7 +181,7 @@ class OpenIDConnect {
];
$this->moduleHandler->alter('openid_connect_user_properties_ignore', $properties_ignore, $context);
// Invoke deprecated hook with deprecation error message.
$this->moduleHandler->alterDeprecated('hook_openid_connect_user_properties_to_skip_alter() is deprecated and will be removed in 8.x-2.0.', 'openid_connect_user_properties_to_skip', $properties_ignore);
$this->moduleHandler->alterDeprecated('hook_openid_connect_user_properties_to_skip_alter() is deprecated and will be removed in 8.x-2.0.', 'openid_connect_user_properties_to_skip', $properties_ignore, $context);
$properties_ignore = array_unique($properties_ignore);
return array_combine($properties_ignore, $properties_ignore);
......@@ -678,6 +678,10 @@ class OpenIDConnect {
}
// Allow other modules to add additional user information.
$this->moduleHandler->invokeAllDeprecated('openid_connect_save_userinfo() is deprecated and will be removed in 8.x-2.0.', 'openid_connect_save_userinfo', [
$account,
$context,
]);
$this->moduleHandler->invokeAll('openid_connect_userinfo_save', [
$account,
$context,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment