Skip to content

Commit

Permalink
fix: cleanup import and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLemarchand committed Oct 14, 2024
1 parent 025b990 commit c274f49
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion front/config.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down
8 changes: 5 additions & 3 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit c274f49

Please sign in to comment.