diff --git a/front/config.form.php b/front/config.form.php index d71b843..4950866 100644 --- a/front/config.form.php +++ b/front/config.form.php @@ -41,7 +41,7 @@ $config::updateConfigValues($_POST); if (isset($_POST["import"])) { if (!$config::importUser($_POST["user"], $_POST["group"])) { - Session::addMessageAfterRedirect(__('No users found for this group', 'okta'), false, ERROR); + Session::addMessageAfterRedirect(__('Could not import users', 'okta'), false, ERROR); } else { Session::addMessageAfterRedirect(__('Users imported successfully', 'okta')); } diff --git a/inc/config.class.php b/inc/config.class.php index 40234a0..9fb2bec 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -212,7 +212,11 @@ private static function createOrUpdateUser($userId) { }; $profile = $distantUser['profile']; $profile += ['id' => $distantUser['id']]; - $userName = $profile[$OidcMappings['name']]; + if (!isset($OidcMappings['name']) || !isset($apiMappings[$OidcMappings['name']])) { + Session::addMessageAfterRedirect(__('No okta mapping found for : ', 'okta') . $OidcMappings['name'], false, ERROR); + return false; + } + $userName = $profile[$apiMappings[$OidcMappings['name']]]; $ID = array_search($userName, $localNames); if (!$ID) { @@ -244,13 +248,11 @@ static function importUser($userId, $groupId = null) { $userList = self::getUsersInGroup($groupId); foreach ($userList as $user) { if (!self::createOrUpdateUser($user['id'])) { - Session::addMessageAfterRedirect(__('Error importing user'), false, ERROR); return false; } } } else { if (!self::createOrUpdateUser($userId)) { - Session::addMessageAfterRedirect(__('Error importing user'), false, ERROR); return false; } }