You are here

function openid_connect_user_load_by_sub in OpenID Connect / OAuth client 7

Loads a user based on a sub-id and a login provider.

2 calls to openid_connect_user_load_by_sub()
openid_connect_complete_authorization in ./openid_connect.module
Complete the authorization after tokens have been retrieved.
openid_connect_connect_current_user in ./openid_connect.module
Connect the current user's account to an external provider.

File

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

Code

function openid_connect_user_load_by_sub($sub, $client_name) {
  $result = db_select('authmap', 'a')
    ->fields('a', array(
    'uid',
    'module',
  ))
    ->condition('authname', $sub)
    ->condition('module', 'openid_connect_' . $client_name)
    ->execute()
    ->fetchAssoc();
  if ($result) {
    $account = user_load($result['uid']);
    if (is_object($account)) {
      return $account;
    }
  }
  return FALSE;
}