You are here

function auth0_update_fields in Auth0 Single Sign On 7.2

1 call to auth0_update_fields()
auth0_update_fields_and_roles in ./auth0.module
Update the field mappings and role mappings for a user based on auth0 user data

File

./auth0.module, line 419

Code

function auth0_update_fields($user_info, $uid, $the_user, &$edit) {
  $auth0_claim_mapping = variable_get('auth0_claim_mapping');
  function_exists('dd') && dd($auth0_claim_mapping, 'auth0_claim_mapping');
  if (isset($auth0_claim_mapping) && !empty($auth0_claim_mapping)) {

    // For each claim mapping, lookup the value, otherwise set to blank
    $mappings = auth0_pipeListToArray($auth0_claim_mapping);
    function_exists('dd') && dd($mappings, 'auth0_claim_mapping as array');

    // Remove mappings handled automatically by the module
    $skip_mappings = array(
      'uid',
      'name',
      'mail',
      'init',
      'is_new',
      'status',
      'pass',
    );
    foreach ($mappings as $mapping) {
      function_exists('dd') && dd($mapping, 'mapping');
      $key = $mapping[1];
      if (in_array($key, $skip_mappings)) {
        function_exists('dd') && dd($mapping, 'skipping mapping handled already by auth0 module');
      }
      else {
        $value = isset($user_info[$mapping[0]]) ? $user_info[$mapping[0]] : '';

        //array()[LANGUAGE_NONE][0]['value'] = 'foo';
        $edit[$key] = array(
          LANGUAGE_NONE => array(
            0 => array(
              'value' => $value,
            ),
          ),
        );
      }
    }
  }
}