|
|
|
@ -92,21 +92,19 @@ if (isset($_GET['sso'])) { |
|
|
|
exit; |
|
|
|
exit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Set chamilo sessions |
|
|
|
|
|
|
|
Session::write('samlUserdata', $auth->getAttributes()); |
|
|
|
|
|
|
|
Session::write('samlNameId', $auth->getNameId()); |
|
|
|
|
|
|
|
Session::write('samlNameIdFormat', $auth->getNameIdFormat()); |
|
|
|
|
|
|
|
Session::write('samlSessionIndex', $auth->getSessionIndex()); |
|
|
|
|
|
|
|
Session::erase('AuthNRequestID'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$keyCloackUserName = Session::read('samlNameId'); |
|
|
|
$keyCloackUserName = Session::read('samlNameId'); |
|
|
|
$userInfo = api_get_user_info_from_username($keyCloackUserName); |
|
|
|
$userInfo = api_get_user_info_from_username($keyCloackUserName); |
|
|
|
|
|
|
|
$attributes = $auth->getAttributes(); |
|
|
|
|
|
|
|
|
|
|
|
if (empty($userInfo)) { |
|
|
|
if (!empty($attributes) && empty($userInfo)) { |
|
|
|
$firstName = reset($attributes['FirstName']); |
|
|
|
$firstName = reset($attributes['FirstName']); |
|
|
|
$lastName = reset($attributes['LastName']); |
|
|
|
$lastName = reset($attributes['LastName']); |
|
|
|
$email = reset($attributes['Email']); |
|
|
|
$email = reset($attributes['Email']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($email)) { |
|
|
|
|
|
|
|
api_not_allowed(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$userId = UserManager::create_user( |
|
|
|
$userId = UserManager::create_user( |
|
|
|
$firstName, |
|
|
|
$firstName, |
|
|
|
$lastName, |
|
|
|
$lastName, |
|
|
|
@ -125,6 +123,13 @@ if (isset($_GET['sso'])) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!empty($userId)) { |
|
|
|
if (!empty($userId)) { |
|
|
|
|
|
|
|
// Set chamilo sessions |
|
|
|
|
|
|
|
Session::write('samlUserdata', $auth->getAttributes()); |
|
|
|
|
|
|
|
Session::write('samlNameId', $auth->getNameId()); |
|
|
|
|
|
|
|
Session::write('samlNameIdFormat', $auth->getNameIdFormat()); |
|
|
|
|
|
|
|
Session::write('samlSessionIndex', $auth->getSessionIndex()); |
|
|
|
|
|
|
|
Session::erase('AuthNRequestID'); |
|
|
|
|
|
|
|
|
|
|
|
// Filling session variables with new data |
|
|
|
// Filling session variables with new data |
|
|
|
Session::write('_uid', $userId); |
|
|
|
Session::write('_uid', $userId); |
|
|
|
Session::write('_user', $userInfo); |
|
|
|
Session::write('_user', $userInfo); |
|
|
|
|