@@ -198,54 +198,49 @@ public String userAuthenticate(
198198 * FAILED LOGIN ATTEMPT LOGIC
199199 * =========================================
200200 */
201- if (mUser == null || mUser .isEmpty ()) {
202- if (!existingUser .isEmpty ()){
203- if (existingUser != null ) {
204-
205- Integer failedAttempt = existingUser .get (0 ).getFailedAttempt () != null
206- ? existingUser .get (0 ).getFailedAttempt ()
207- : 0 ;
208-
209- failedAttempt ++;
201+ if (!existingUser .isEmpty ()){
202+ if (existingUser != null ) {
210203
211- existingUser .get (0 ).setFailedAttempt (failedAttempt );
204+ Integer failedAttempt = existingUser .get (0 ).getFailedAttempt () != null
205+ ? existingUser .get (0 ).getFailedAttempt ()
206+ : 0 ;
212207
213- iemrAdminUserServiceImpl . save ( existingUser . get ( 0 )) ;
208+ failedAttempt ++ ;
214209
215- int remainingAttempts = 5 - failedAttempt ;
210+ existingUser . get ( 0 ). setFailedAttempt ( failedAttempt ) ;
216211
217- // Lock account on 5th attempt
218- if (failedAttempt >= 5 ) {
212+ iemrAdminUserServiceImpl .save (existingUser .get (0 ));
219213
214+ int remainingAttempts = 5 - failedAttempt ;
220215
216+ // Lock account on 5th attempt
217+ if (failedAttempt >= 5 ) {
221218
222- response .setError (new IEMRException (
223- "Your account has been locked due to multiple failed login attempts." ));
224- return response .toString ();
225- }
226219
227- // Warning on 3rd attempt
228- if (failedAttempt == 4 ) {
229220
221+ response .setError (new IEMRException (
222+ "Your account has been locked due to multiple failed login attempts." ));
223+ return response .toString ();
224+ }
230225
231- response .setError (new IEMRException (
232- "Invalid username or password. Remaining attempts: "
233- + remainingAttempts
234- + ". If you enter wrong username or password again, your account will be locked." ));
235- return response .toString ();
236- }
226+ // Warning on 3rd attempt
227+ if (failedAttempt == 4 ) {
237228
238229
239- response .setError (new IEMRException (
240- "Invalid username or password. Remaining attempts: "
241- + remainingAttempts ));
242- return response .toString ();
230+ response .setError (new IEMRException (
231+ "Invalid username or password. Remaining attempts: "
232+ + remainingAttempts
233+ + ". If you enter wrong username or password again, your account will be locked." ));
234+ return response .toString ();
235+ }
243236
244- }
245- }
246237
238+ response .setError (new IEMRException (
239+ "Invalid username or password. Remaining attempts: "
240+ + remainingAttempts ));
241+ return response .toString ();
247242
248- throw new IEMRException ( "Invalid username or password." );
243+ }
249244 }
250245
251246 /*
0 commit comments