Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,13 @@ private void handleFailedLoginAttempt(User user, int failedAttemptThreshold) thr
user.setFailedAttempt(currentAttempts + 1);
iEMRUserRepositoryCustom.save(user);
logger.warn("User Password Wrong");
throw new IEMRException("Invalid username or password");
int remainingAttempts = failedAttemptThreshold - (currentAttempts + 1);
if (remainingAttempts == 1) {
throw new IEMRException(
"Invalid username or password. Remaining attempts: 1. "
+ "If you enter wrong username or password again, your account will be locked.");
}
throw new IEMRException("Invalid username or password. Remaining attempts: " + remainingAttempts);
} else {
java.sql.Timestamp lockTime = new java.sql.Timestamp(System.currentTimeMillis());
user.setFailedAttempt(currentAttempts + 1);
Expand All @@ -317,7 +323,8 @@ private void handleFailedLoginAttempt(User user, int failedAttemptThreshold) thr
iEMRUserRepositoryCustom.save(user);
logger.warn("User Account has been locked after reaching the limit of {} failed login attempts.",
failedAttemptThreshold);
throw new IEMRException(generateLockoutErrorMessage(lockTime));
throw new IEMRException(
"Your account has been locked due to multiple failed login attempts. Please contact administrator.");
}
}

Expand Down
Loading