Skip to content

Commit a0a362f

Browse files
authored
fix:user enumeration (#242)
1 parent 9a7c741 commit a0a362f

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/main/java/com/iemr/common/controller/users/IEMRAdminController.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ public String superUserAuthenticate(
519519
response.setResponse(responseObj.toString());
520520
} catch (Exception e) {
521521
logger.error("userAuthenticate failed with error " + e.getMessage(), e);
522-
response.setError(5000, "Authentication failed. Please try again later."); // Generic fallback
522+
response.setError(e);
523523
}
524524
logger.info("userAuthenticate response " + response.toString());
525525
return response.toString();
@@ -620,10 +620,10 @@ public String forgetPassword(
620620

621621
if (mUsers == null || mUsers.size() <= 0) {
622622
logger.error("User not found");
623-
throw new IEMRException("Request failed, please try again later");
623+
throw new IEMRException("If the username is valid, you will be asked a security question");
624624
} else if (mUsers.size() > 1) {
625625
logger.error("More than 1 user found");
626-
throw new IEMRException("Request failed. Please retry again");
626+
throw new IEMRException("If the username is valid, you will be asked a security question");
627627

628628
} else if (mUsers.size() == 1) {
629629
List<Map<String, String>> quesAnsList = new ArrayList<>();
@@ -645,7 +645,7 @@ public String forgetPassword(
645645
}
646646
} catch (Exception e) {
647647
logger.error("forgetPassword failed with error " + e.getMessage(), e);
648-
response.setError(5000, "ForgetPassword failed.");
648+
response.setError(e);
649649
}
650650
logger.info("forgetPassword response " + response.toString());
651651
return response.toString();
@@ -734,7 +734,7 @@ public String changePassword(
734734
response.setResponse(changeReqResult);
735735
} catch (Exception e) {
736736
logger.error("changePassword failed with error " + e.getMessage(), e);
737-
response.setError(5000, "Password change failed. Please try again later.");
737+
response.setError(e);
738738
}
739739
logger.info("changePassword response " + response.toString());
740740
return response.toString();
@@ -752,7 +752,7 @@ public String saveUserSecurityQuesAns(
752752
response.setResponse(responseData);
753753
} catch (Exception e) {
754754
logger.error("saveUserSecurityQuesAns failed with error " + e.getMessage(), e);
755-
response.setError(5000, "Failed to save security questions. Please try again later.");
755+
response.setError(e);
756756
}
757757
logger.info("saveUserSecurityQuesAns response " + response.toString());
758758
return response.toString();
@@ -1058,7 +1058,7 @@ public String userAuthenticateByEncryption(
10581058
response.setResponse(responseObj.toString());
10591059
} catch (Exception e) {
10601060
logger.error("userAuthenticateByEncryption failed with error " + e.getMessage(), e);
1061-
response.setError(5000, "Request failed. Please try again.");
1061+
response.setError(e);
10621062
}
10631063
logger.info("userAuthenticateByEncryption response " + response.toString());
10641064
return response.toString();
@@ -1076,7 +1076,7 @@ public String getrolewrapuptime(@PathVariable("roleID") Integer roleID) {
10761076
}
10771077
response.setResponse(test.toString());
10781078
} catch (Exception e) {
1079-
response.setError(5000, "Request failed. Please try again.");
1079+
response.setError(e);
10801080
}
10811081
return response.toString();
10821082
}
@@ -1104,7 +1104,7 @@ public String validateSecurityQuestionAndAnswer(
11041104
throw new IEMRException("Invalid Request");
11051105
} catch (Exception e) {
11061106
logger.error("validateSecurityQuestionAndAnswer failed: {}", e.toString());
1107-
response.setError(5000, "Request failed. Please try again.");
1107+
response.setError(5000, e.getMessage());
11081108
}
11091109
logger.info("validateSecurityQuestionAndAnswer API response" + response.toString());
11101110
return response.toString();
@@ -1160,7 +1160,7 @@ public String userAuthenticateBhavya(
11601160
response.setResponse(responseObj.toString());
11611161
} catch (Exception e) {
11621162
logger.error("userAuthenticate failed with error " + e.getMessage(), e);
1163-
response.setError(5000, "Authentication failed. Please try again.");
1163+
response.setError(e);
11641164
}
11651165
logger.info("userAuthenticate response " + response.toString());
11661166
return response.toString();

0 commit comments

Comments
 (0)