Handled non-existent user login error

This commit is contained in:
rajesh
2026-03-05 15:42:03 +05:30
parent 7d6c55cf92
commit 4726cd5104
4 changed files with 6 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ public class GepafinConstant {
public static final String USER_UPDATED_SUCCESS_MSG = "user.updated.success"; public static final String USER_UPDATED_SUCCESS_MSG = "user.updated.success";
public static final String USER_DELETED_SUCCESS_MSG = "user.deleted.success"; public static final String USER_DELETED_SUCCESS_MSG = "user.deleted.success";
public static final String USER_NOT_FOUND_MSG = "user.not.found"; public static final String USER_NOT_FOUND_MSG = "user.not.found";
public static final String INVALID_USERNAME_AND_PASSWORD = "invalid.username.or.password";
public static final String CREATE_USER_ERROR_MSG = "create_user_error_msg"; public static final String CREATE_USER_ERROR_MSG = "create_user_error_msg";
public static final String UPDATE_USER_ERROR_MSG = "update_user_error_msg"; public static final String UPDATE_USER_ERROR_MSG = "update_user_error_msg";
public static final String DELETE_USER_ERROR_MSG = "delete_user_error_msg"; public static final String DELETE_USER_ERROR_MSG = "delete_user_error_msg";

View File

@@ -96,7 +96,7 @@ public class AuthenticationService {
RoleStatusEnum.ROLE_BENEFICIARY.getValue() RoleStatusEnum.ROLE_BENEFICIARY.getValue()
).orElseThrow(() -> new ResourceNotFoundException( ).orElseThrow(() -> new ResourceNotFoundException(
Status.NOT_FOUND, Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG) Translator.toLocale(GepafinConstant.INVALID_USERNAME_AND_PASSWORD)
)); ));
String emailWithHubId = loginReq.getEmail()+":"+loginReq.getHubUuid(); String emailWithHubId = loginReq.getEmail()+":"+loginReq.getHubUuid();
@@ -115,7 +115,7 @@ public class AuthenticationService {
createSuccessLoginAttempt(loginAttemptEntity); createSuccessLoginAttempt(loginAttemptEntity);
} catch (Exception e) { } catch (Exception e) {
log.info("Authentication failed for email: {}", loginReq.getEmail()); log.info("Authentication failed for email: {}", loginReq.getEmail());
loginAttemptEntity.setUserId(user.getId()); // loginAttemptEntity.setUserId(user.getId());
createFailedLoginAttempt(loginAttemptEntity, e.getMessage()); createFailedLoginAttempt(loginAttemptEntity, e.getMessage());
throw e; throw e;
} }
@@ -238,7 +238,7 @@ public class AuthenticationService {
return getJWTTokenBean(userEntity, Boolean.TRUE, loginAttempt.getId(),null); return getJWTTokenBean(userEntity, Boolean.TRUE, loginAttempt.getId(),null);
} catch (Exception e) { } catch (Exception e) {
log.info("Authentication login failed for email: {}",e.getMessage()); log.info("Authentication login failed for email: {}",e.getMessage());
loginAttemptEntity.setUserId(userId); // loginAttemptEntity.setUserId(userId);
createFailedLoginAttempt(loginAttemptEntity, e.getMessage()); createFailedLoginAttempt(loginAttemptEntity, e.getMessage());
throw e; throw e;
} }

View File

@@ -2,6 +2,7 @@ user.created.success=User created successfully.
user.updated.success=User updated successfully. user.updated.success=User updated successfully.
user.deleted.success=User deleted successfully. user.deleted.success=User deleted successfully.
user.not.found=User not found. user.not.found=User not found.
invalid.username.or.password= Invalid username or password.
create_user_error_msg=An error occurred while creating the user. create_user_error_msg=An error occurred while creating the user.
update_user_error_msg=An error occurred while updating the user. update_user_error_msg=An error occurred while updating the user.
delete_user_error_msg=An error occurred while deleting the user. delete_user_error_msg=An error occurred while deleting the user.

View File

@@ -2,6 +2,7 @@ user.created.success=Utente creato con successo.
user.updated.success=Utente aggiornato con successo. user.updated.success=Utente aggiornato con successo.
user.deleted.success=Utente eliminato con successo. user.deleted.success=Utente eliminato con successo.
user.not.found=Utente non trovato. user.not.found=Utente non trovato.
invalid.username.or.password= Nome utente o password non validi.
create_user_error_msg=Si ? verificato un errore durante la creazione dell'utente. create_user_error_msg=Si ? verificato un errore durante la creazione dell'utente.
update_user_error_msg=Si ? verificato un errore durante l'aggiornamento dell'utente. update_user_error_msg=Si ? verificato un errore durante l'aggiornamento dell'utente.
delete_user_error_msg=Si ? verificato un errore durante l'eliminazione dell'utente. delete_user_error_msg=Si ? verificato un errore durante l'eliminazione dell'utente.