Merge branch 'feature/GEPAFINBE-31' of https://github.com/Kitzanos/GEPAFIN-BE into feature/GEPAFINBE-31
This commit is contained in:
@@ -5,11 +5,15 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LoginAttemptReq;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LoginAttemptPageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.LoginAttemptService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.LoginAttemptApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
@@ -38,8 +42,15 @@ public class LoginAttemptApiController implements LoginAttemptApi {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<LoginAttemptPageableResponseBean<List<LoginAttemptEntity>>> getLoginAttemptsList(HttpServletRequest request, Integer pageNo, Integer pageLimit) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Get login attempt list" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_LOGIN_ATTEMPT_LIST).build());
|
||||
|
||||
LoginAttemptPageableResponseBean<List<LoginAttemptEntity>> response = loginAttemptService.getLoginAttemptsList(request, pageNo, pageLimit);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(response);
|
||||
}
|
||||
@@ -50,6 +61,10 @@ public class LoginAttemptApiController implements LoginAttemptApi {
|
||||
String userIdString = (String) userInfo.get("userId");
|
||||
UserEntity currentUser = userService.getUserEntityById(Long.parseLong(userIdString));
|
||||
loginAttemptReq.setUserName(currentUser.getEmail());
|
||||
|
||||
/** This code is responsible for creating user action logs for the "add login attempt" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT).actionContext(UserActionContextEnum.ADD_LOGIN_ATTEMPT).build());
|
||||
|
||||
loginAttemptService.createLoginAttempt(loginAttemptReq, request);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGIN_ATTEMPTED_CREATED_SUCCESSFULLY)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user