Resolved conflicts
This commit is contained in:
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.entities.LoginAttemptEntity;
|
||||
import net.gepafin.tendermanagement.entities.SamlResponseEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.LoginAttemptResultEnum;
|
||||
import net.gepafin.tendermanagement.enums.LoginAttemptTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||
@@ -40,6 +37,7 @@ import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -95,15 +93,22 @@ public class AuthenticationService {
|
||||
LoginAttemptEntity loginAttemptEntity = prepareLoginAttemptEntity(loginReq, request);
|
||||
try {
|
||||
log.info("Attempting login for email: {}", loginReq.getEmail());
|
||||
user = userRepository.findUserExcludingRoleType(
|
||||
loginReq.getEmail(),
|
||||
loginReq.getHubUuid(),
|
||||
RoleStatusEnum.ROLE_BENEFICIARY.getValue()
|
||||
).orElseThrow(() -> new ResourceNotFoundException(
|
||||
Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)
|
||||
));
|
||||
|
||||
String emailWithHubId = loginReq.getEmail()+":"+loginReq.getHubUuid();
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(
|
||||
emailWithHubId, loginReq.getPassword());
|
||||
Authentication authentication = this.authenticationManager.authenticate(authenticationToken);
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
log.info("Authentication successful for email: {}", loginReq.getEmail());
|
||||
user = userRepository.findByEmailIgnoreCaseAndHubUniqueUuid(loginReq.getEmail(), loginReq.getHubUuid())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||
|
||||
loginAttemptEntity.setUserId(user.getId());
|
||||
if (Boolean.FALSE.equals(UserStatusEnum.ACTIVE.getValue().equals(user.getStatus()))) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -78,7 +79,7 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Map<String, Object> checkVatNumber(HttpServletRequest request, String vatNumber) {
|
||||
public VatCheckResponseBean checkVatNumber(HttpServletRequest request, String vatNumber) {
|
||||
return vatCheckDao.checkVatNumber(vatNumber);
|
||||
}
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
import net.gepafin.tendermanagement.service.NotificationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.listOf;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class NotificationServiceImpl implements NotificationService {
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Override
|
||||
public NotificationResponse sendNotification(Long userId, NotificationReq notificationReq, Long companyId) {
|
||||
|
||||
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
|
||||
notificationReq.setUserId(userId);
|
||||
notificationReq.setCompanyIds(listOf(companyId));
|
||||
return notificationDao.sendNotification(notificationReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationResponse getNotificationById(HttpServletRequest servletRequest, Long id) {
|
||||
|
||||
return notificationDao.getNotificationById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotificationResponse> getNotificationByUserId(HttpServletRequest servletRequest, Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
|
||||
return notificationDao.getNotificationByUserId(userId, companyId, statuses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationResponse updateNotificationStatus(HttpServletRequest request, Long id, NotificationEnum status) {
|
||||
|
||||
return notificationDao.updateNotificationStatus(id, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotification(HttpServletRequest request, Long id) {
|
||||
|
||||
notificationDao.deleteNotification(id);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NotificationResponse> getNotificationsByCompanyIdAndUserId(Long userId, Long companyId, List<NotificationEnum> statuses) {
|
||||
return notificationDao.getNotificationByCompanyIdAndUserId(userId, companyId, statuses);
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,8 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
return userDao.initiatePasswordReset(resetReq);
|
||||
public void initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
userDao.initiatePasswordReset(resetReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user