Skip to content

Commit

Permalink
[#173] Report warning message from LDAP backend to users.
Browse files Browse the repository at this point in the history
When updating a login name in the LDAP backend there is a risk of side
effects. With this change, we are able to report the success message
from the backend through the UI instead of overwriting it with another
string, so we can warn users when doing that operation.
  • Loading branch information
jaragunde committed Mar 20, 2023
1 parent 73b21e5 commit e0fd789
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
7 changes: 5 additions & 2 deletions model/dao/UserDAO/HybridUserDAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,16 @@ public function getJourneyHistory($userId) {
*
* This function updates the data of a User by its {@link UserVO}.
* WARNING: this function allows to update to a name that does not exist in LDAP.
* Do we really want this behavior?
* A user with a name not matching the LDAP won't be able to log in, this should be a
* transitory situation while the name is not updated in both places.
*
* @param UserVO $userVO the {@link UserVO} with the data we want to update on database.
* @return OperationResult the result {@link OperationResult} with information about operation status
*/
public function update(UserVO $userVO) {
return parent::update($userVO);
$result = parent::update($userVO);
$result->setMessage("Warning: user names not matching LDAP won't be able to login.");
return $result;
}

/** User creator for LDAP/PostgreSQL Hybrid.
Expand Down
9 changes: 6 additions & 3 deletions web/services/createUsersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,14 @@

} while ($parser->read());


$successMessage = "";
foreach((array)$createUsers as $createUser)
{
$result = UsersFacade::CreateUser($createUser);
if (!$result->getIsSuccessful()) {
if ($result->getIsSuccessful()) {
$successMessage .= $result->getMessage() . "\n";
}
else {
http_response_code($result->getResponseCode());
$string = "<return service='createUsers'><error id='" . $result->getErrorNumber() . "'>" .
$result->getMessage() . "</error></return>";
Expand Down Expand Up @@ -193,7 +196,7 @@
if (!$string)
{

$string = "<return service='createUsers'><ok>Operation Success!</ok><users>";
$string = "<return service='createUsers'><ok>" . $successMessage . "</ok><users>";

foreach((array) $createUsers as $createUser)
{
Expand Down
8 changes: 6 additions & 2 deletions web/services/deleteUsersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,15 @@
// we can ignore this error
}

$successMessage = "";
if (count($deleteUsers) >= 1)
foreach((array)$deleteUsers as $user)
{
$result = UsersFacade::DeleteUser($user);
if (!$result->getIsSuccessful()) {
if ($result->getIsSuccessful()) {
$successMessage .= $result->getMessage() . "\n";
}
else {
http_response_code($result->getResponseCode());
$string = "<return service='updateUsers'><error id='" . $result->getErrorNumber() . "'>" .
$result->getMessage() . "</error></return>";
Expand All @@ -140,7 +144,7 @@


if (!$string)
$string = "<return service='deleteUsers'><ok>Operation Success!</ok></return>";
$string = "<return service='deleteUsers'><ok>" . $successMessage . "</ok></return>";

} while (false);

Expand Down
9 changes: 6 additions & 3 deletions web/services/updateUsersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,14 @@

} while ($parser->read());


$successMessage = "";
foreach((array)$updateUsers as $updateUser)
{
$result = UsersFacade::UpdateUser($updateUser);
if (!$result->getIsSuccessful()) {
if ($result->getIsSuccessful()) {
$successMessage .= $result->getMessage() . "\n";
}
else {
http_response_code($result->getResponseCode());
$string = "<return service='updateUsers'><error id='" . $result->getErrorNumber() . "'>" .
$result->getMessage() . "</error></return>";
Expand Down Expand Up @@ -230,7 +233,7 @@
if (!$string)
{

$string = "<return service='updateUsers'><ok>Operation Success!</ok><users>";
$string = "<return service='updateUsers'><ok>" . $successMessage . "</ok><users>";

foreach((array) $updateUsers as $updateUser)
{
Expand Down
8 changes: 6 additions & 2 deletions web/viewUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ function areas(val){
'load': function() {
userGrid.getTopToolbar().getComponent('userFilter').focus();
},
'write': function() {
App.setAlert(true, "Users Changes Saved");
'write': function (proxy, type, action, eOpts, res) {
const successTags = eOpts.raw.getElementsByTagName("ok");
if (successTags.length > 0)
App.setAlert(true, successTags[0].innerHTML);
else
App.setAlert(true, "Users Changes Saved");
},
'exception': function(proxy, type, action, eOpts, res) {
let parser = new DOMParser();
Expand Down

0 comments on commit e0fd789

Please sign in to comment.