diff --git a/plugins/cas_auth_unl/start.php b/plugins/cas_auth_unl/start.php index 97e12b7fa40e05e1076cfe3d39d3e9f6f683fdee..c5b8b6acf012b2b72da56be438a081f6dc092efa 100644 --- a/plugins/cas_auth_unl/start.php +++ b/plugins/cas_auth_unl/start.php @@ -133,9 +133,15 @@ class elggSimpleCas { // User exists, return the user object return $user; } else { - // Valid login but user doesn't exist + // Valid CAS login but user hasn't been registered in Planet Red yet + // We end up going through here twice, first time grabs email from Peoplefinder and forwards to the getemail validation page to ask + // them if the email is correct, then when we return with the email we register the user in elgg + $pf_user_info = peoplefinderServices($casusername); - $name = $pf_user_info->cn; + if(!empty($pf_user_info->cn)) + $name = $pf_user_info->cn; + else //A peoplefinder record does not exist because they've set their privacy flag so set display name to username so register_user below doesn't break + $name = $username; if (empty($email)){ if($pf_user_info->mail) @@ -149,17 +155,19 @@ class elggSimpleCas { if ($user_guid = register_user($username, $password, $name, $email, false, 0, '', true)) { $thisuser = get_user($user_guid); - //pre-populate profile fields with data from Peoplefinder Services - $address = $pf_user_info->formatPostalAddress(); - $thisuser->profile_country = 'USA'; - $thisuser->profile_state = $address['region']; - $thisuser->profile_city = $address['locality']; - if($address['locality'] == 'Omaha') { - $thisuser->longitude = -95.9; - $thisuser->latitude = 41.25; - } else { //this is going to cover Lincoln and everyone else - $thisuser->longitude = -96.7; - $thisuser->latitude = 40.82; + if(!empty($pf_user_info->cn)){ + //pre-populate profile fields with data from Peoplefinder Services if available + $address = $pf_user_info->formatPostalAddress(); + $thisuser->profile_country = 'USA'; + $thisuser->profile_state = $address['region']; + $thisuser->profile_city = $address['locality']; + if($address['locality'] == 'Omaha') { + $thisuser->longitude = -95.9; + $thisuser->latitude = 41.25; + } else { //this is going to cover Lincoln and everyone else + $thisuser->longitude = -96.7; + $thisuser->latitude = 40.82; + } } return $thisuser;