Added user action and versioning for login attempt.

This commit is contained in:
piyushkag
2024-11-24 21:29:32 +05:30
parent 5f5321c71e
commit 64919a455c
3 changed files with 23 additions and 10 deletions

View File

@@ -38,18 +38,12 @@ public class LoginAttemptDao {
public LoginAttemptEntity createLoginAttempt(LoginAttemptEntity loginAttemptEntity) {
VersionActionTypeEnum actionType;
LoginAttemptEntity oldLoginAttemptEntity = Utils.getClonedEntityForData(loginAttemptEntity);
loginAttemptEntity.setAttemptDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
if(loginAttemptEntity.getId() != null ) {
actionType = VersionActionTypeEnum.UPDATE;
}else{
actionType = VersionActionTypeEnum.INSERT;
oldLoginAttemptEntity = null;
}
loginAttemptEntity = loginAttemptRepository.save(loginAttemptEntity);
loginAttemptEntity = loginAttemptRepository.save(loginAttemptEntity);
/** This code is responsible for adding a version history log for "Create Login Attempt" operation. **/
loggingUtil.addVersionHistoryWithoutToken(VersionHistoryRequest.builder().actionType(actionType).request(request).oldData(oldLoginAttemptEntity).newData(loginAttemptEntity).build());
loggingUtil.addVersionHistoryWithoutToken(
VersionHistoryRequest.builder().actionType(VersionActionTypeEnum.INSERT).request(request).oldData(null).newData(loginAttemptEntity).build());
return loginAttemptEntity;
}