You are here

function gauth_login_find_existing_user in Google Auth 7

Same name and namespace in other branches
  1. 7.2 gauth_login/gauth_login.module \gauth_login_find_existing_user()

Finds an existing user based on info from Google.

Parameters

array $info: The 'userinfo' array from OAuth.

Return value

object|NULL An existing Drupal user object if found; otherwise NULL.

1 call to gauth_login_find_existing_user()
gauth_login_gauth_google_response in gauth_login/gauth_login.module
Implementation of hook_gauth_google_response().

File

gauth_login/gauth_login.module, line 139
Google Auth Api for drupal.

Code

function gauth_login_find_existing_user($info) {

  // First, see if there is a user with the given e-mail.
  if ($new_user = user_load_by_mail($info['email'])) {
    return $new_user;
  }

  // Next, see if any modules have another way of tracking down existing users.
  foreach (module_implements('gauth_login_find_existing_user') as $module) {
    if ($new_user = module_invoke($module, 'gauth_login_find_existing_user', $info)) {
      return $new_user;
    }
  }
}