You are here

function openid_connect_create_user in OpenID Connect / OAuth client 7

Same name and namespace in other branches
  1. 8 openid_connect.module \openid_connect_create_user()

Creates a user indicating sub-id and login provider.

Parameters

string $sub: The subject identifier.

array $userinfo: The user claims, containing at least 'email'.

string $client_name: The machine name of the client.

Return value

object|false The user object or FALSE on failure.

1 call to openid_connect_create_user()
openid_connect_complete_authorization in ./openid_connect.module
Complete the authorization after tokens have been retrieved.

File

./openid_connect.module, line 366
A pluggable client implementation for the OpenID Connect protocol.

Code

function openid_connect_create_user($sub, $userinfo, $client_name) {
  $edit = array(
    'name' => openid_connect_generate_username($sub, $userinfo, $client_name),
    'pass' => user_password(),
    'mail' => $userinfo['email'],
    'init' => $userinfo['email'],
    'status' => 1,
    'openid_connect_client' => $client_name,
    'openid_connect_sub' => $sub,
  );
  return user_save(NULL, $edit);
}