public function OpenIDConnectAuthmap::createAssociation in OpenID Connect / OAuth client 8
Create a local to remote account association.
Parameters
object $account: A user account object.
string $client_name: The client name.
string $sub: The remote subject identifier.
File
- src/
OpenIDConnectAuthmap.php, line 55
Class
- OpenIDConnectAuthmap
- The OpenID Connect authmap service.
Namespace
Drupal\openid_connectCode
public function createAssociation($account, $client_name, $sub) {
$existing_accounts = $this
->getConnectedAccounts($account, $client_name);
// Only create record if association to account doesn't exist yet.
if (!isset($existing_accounts[$client_name]) || $existing_accounts[$client_name] !== $sub) {
$this->connection
->insert('openid_connect_authmap')
->fields([
'uid' => $account
->id(),
'client_name' => $client_name,
'sub' => $sub,
])
->execute();
}
}