@@ -65,18 +65,20 @@ public class LoginServlet extends HttpServlet {
6565 * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
6666 * javax.servlet.http.HttpServletResponse)
6767 */
68+
6869 @ Override
6970 protected void doPost (HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException {
7071 HttpSession httpSession = request .getSession ();
7172
73+ Integer loginAttemptsByUser ;
7274 String ipAddress = request .getRemoteAddr ();
7375 Integer loginAttempts = loginAttemptsByIP .get (ipAddress );
7476 if (loginAttempts == null ) {
7577 loginAttempts = 1 ;
7678 }
7779
7880 loginAttempts ++;
79-
81+ loginAttemptsByUser = loginAttempts - 1 ;
8082 boolean lockedOut = false ;
8183 // look up the allowed # of attempts per IP
8284 Integer allowedLockoutAttempts = 100 ;
@@ -178,7 +180,14 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
178180 catch (ContextAuthenticationException e ) {
179181 // set the error message for the user telling them
180182 // to try again
181- httpSession .setAttribute (WebConstants .OPENMRS_ERROR_ATTR , "auth.password.invalid" );
183+ Integer maximumAlowedAttempts = 7 ;
184+ if (loginAttemptsByUser <= maximumAlowedAttempts ) {
185+ httpSession .setAttribute (WebConstants .OPENMRS_ERROR_ATTR , "auth.password.invalid" );
186+ }
187+
188+ if (loginAttemptsByUser > maximumAlowedAttempts ) {
189+ httpSession .setAttribute (WebConstants .OPENMRS_ERROR_ATTR , "legacyui.lockedOutMessage" );
190+ }
182191 }
183192
184193 }
0 commit comments