user_set_authmaps

Definition

user_set_authmaps($account, $authmaps)
modules/user/user.module, line 1258

Description

Save mappings of which external authentication module(s) authenticated a user. Maps external usernames to user ids in the users table.

See also

user_external_login_register()

Parameters

$account A user object.

$authmaps An associative array with a compound key and the username as the value. The key is made up of 'authname_' plus the name of the external authentication module.

Code

<?php
function user_set_authmaps($account, $authmaps) {
  foreach ($authmaps as $key => $value) {
    $module = explode('_', $key, 2);
    if ($value) {
      db_merge('authmap')
        ->key(array(
        'uid' => $account->uid,
        'module' => $module[1],
        ))
        ->fields(array(
        'authname' => $value,
        ))
        ->execute();
    }
    else {
      db_delete('authmap')->condition('uid', $account->uid)->condition('module', $module[1])->execute();
    }
  }
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.