이메일 소문자 처리
This commit is contained in:
@@ -262,9 +262,10 @@ public class OrgRegisterFacadeImpl implements OrgRegisterFacade {
|
|||||||
// PortalOrgService를 통한 기관 등록
|
// PortalOrgService를 통한 기관 등록
|
||||||
PortalOrg newOrg = portalOrgService.registerOrgFromDTOWithFile(orgDTO, uploadedFile);
|
PortalOrg newOrg = portalOrgService.registerOrgFromDTOWithFile(orgDTO, uploadedFile);
|
||||||
|
|
||||||
// 새 사용자 생성
|
// 새 사용자 생성 (이메일 소문자 변환 적용)
|
||||||
existingUser.setLoginId(newEmail);
|
String normalizedNewEmail = newEmail != null ? newEmail.toLowerCase() : null;
|
||||||
existingUser.setEmailAddr(newEmail);
|
existingUser.setLoginId(normalizedNewEmail);
|
||||||
|
existingUser.setEmailAddr(normalizedNewEmail);
|
||||||
existingUser.setPortalOrg(newOrg);
|
existingUser.setPortalOrg(newOrg);
|
||||||
existingUser.setRoleCode(PortalUserEnums.RoleCode.ROLE_CORP_MANAGER);
|
existingUser.setRoleCode(PortalUserEnums.RoleCode.ROLE_CORP_MANAGER);
|
||||||
existingUser.setUserStatus(PortalUserEnums.UserStatus.READY);
|
existingUser.setUserStatus(PortalUserEnums.UserStatus.READY);
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ public class PortalUserAuthService implements UserDetailsService {
|
|||||||
@Transactional(noRollbackFor = UsernameNotFoundException.class)
|
@Transactional(noRollbackFor = UsernameNotFoundException.class)
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
try {
|
try {
|
||||||
PortalUser portalUser = findByEmailAddr(username);
|
// 이메일 소문자 변환 적용 (대소문자 구분 없이 로그인 가능하도록)
|
||||||
|
String normalizedUsername = username != null ? username.toLowerCase() : null;
|
||||||
|
PortalUser portalUser = findByEmailAddr(normalizedUsername);
|
||||||
RoleCode userRole = portalUser.getRoleCode() == null ? RoleCode.ROLE_USER : portalUser.getRoleCode();
|
RoleCode userRole = portalUser.getRoleCode() == null ? RoleCode.ROLE_USER : portalUser.getRoleCode();
|
||||||
List<String> roles = portalProperties.getPortalSecurity().get(userRole);
|
List<String> roles = portalProperties.getPortalSecurity().get(userRole);
|
||||||
PortalAuthenticatedUser authenticatedUser = portalUserMapper.portalUserToAuthenticatedUser(portalUser);
|
PortalAuthenticatedUser authenticatedUser = portalUserMapper.portalUserToAuthenticatedUser(portalUser);
|
||||||
|
|||||||
@@ -46,11 +46,15 @@ public class PortalUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<PortalUser> findByLoginId(String loginId) {
|
public Optional<PortalUser> findByLoginId(String loginId) {
|
||||||
return portalUserRepository.findByLoginId(loginId);
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedLoginId = loginId != null ? loginId.toLowerCase() : null;
|
||||||
|
return portalUserRepository.findByLoginId(normalizedLoginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PortalUser findByEmailAddr(String emailAddr) {
|
public PortalUser findByEmailAddr(String emailAddr) {
|
||||||
return portalUserRepository.findPortalUserByEmailAddr(emailAddr)
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedEmail = emailAddr != null ? emailAddr.toLowerCase() : null;
|
||||||
|
return portalUserRepository.findPortalUserByEmailAddr(normalizedEmail)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("해당 이메일 주소의 사용자를 찾을 수 없습니다."));
|
.orElseThrow(() -> new IllegalArgumentException("해당 이메일 주소의 사용자를 찾을 수 없습니다."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +63,9 @@ public class PortalUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean existsByLoginId(String loginId) {
|
public boolean existsByLoginId(String loginId) {
|
||||||
return portalUserRepository.existsByLoginId(loginId);
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedLoginId = loginId != null ? loginId.toLowerCase() : null;
|
||||||
|
return portalUserRepository.existsByLoginId(normalizedLoginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkOrgHasOtherUsers(PortalOrg portalOrg) {
|
public boolean checkOrgHasOtherUsers(PortalOrg portalOrg) {
|
||||||
@@ -137,11 +143,13 @@ public class PortalUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mapDtoToEntity(PortalUser user, PortalUserRegistrationDTO dto) {
|
private void mapDtoToEntity(PortalUser user, PortalUserRegistrationDTO dto) {
|
||||||
user.setLoginId(dto.getLoginId());
|
// 이메일 소문자 변환 적용 (대소문자 구분 없이 로그인 가능하도록)
|
||||||
|
String normalizedEmail = dto.getLoginId() != null ? dto.getLoginId().toLowerCase() : null;
|
||||||
|
user.setLoginId(normalizedEmail);
|
||||||
user.setUserName(dto.getUserName());
|
user.setUserName(dto.getUserName());
|
||||||
user.setPasswordHash(passwordEncoder.encode(dto.getPassword()));
|
user.setPasswordHash(passwordEncoder.encode(dto.getPassword()));
|
||||||
user.setMobileNumber(dto.getMobileNumber());
|
user.setMobileNumber(dto.getMobileNumber());
|
||||||
user.setEmailAddr(dto.getLoginId());
|
user.setEmailAddr(normalizedEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +184,9 @@ public class PortalUserService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkPassword(String loginId, String inputPassword) {
|
public boolean checkPassword(String loginId, String inputPassword) {
|
||||||
PortalUser user = portalUserRepository.findByLoginId(loginId)
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedLoginId = loginId != null ? loginId.toLowerCase() : null;
|
||||||
|
PortalUser user = portalUserRepository.findByLoginId(normalizedLoginId)
|
||||||
.orElseThrow(() -> new IllegalArgumentException("해당 사용자를 찾을 수 없습니다."));
|
.orElseThrow(() -> new IllegalArgumentException("해당 사용자를 찾을 수 없습니다."));
|
||||||
return passwordEncoder.matches(inputPassword, user.getPasswordHash());
|
return passwordEncoder.matches(inputPassword, user.getPasswordHash());
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -49,6 +49,8 @@ public class PortalAuthenticationFailureHandler implements AuthenticationFailure
|
|||||||
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {AuthenticationException.class, UserNotFoundException.class})
|
@Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {AuthenticationException.class, UserNotFoundException.class})
|
||||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
|
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
|
||||||
String username = request.getParameter("id");
|
String username = request.getParameter("id");
|
||||||
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedUsername = username != null ? username.toLowerCase() : null;
|
||||||
String ip = request.getRemoteAddr();
|
String ip = request.getRemoteAddr();
|
||||||
String sessionId = request.getSession().getId();
|
String sessionId = request.getSession().getId();
|
||||||
|
|
||||||
@@ -56,8 +58,8 @@ public class PortalAuthenticationFailureHandler implements AuthenticationFailure
|
|||||||
logger.error(exception.getLocalizedMessage());
|
logger.error(exception.getLocalizedMessage());
|
||||||
} else if (!(exception instanceof UsernameNotFoundException)) {
|
} else if (!(exception instanceof UsernameNotFoundException)) {
|
||||||
try {
|
try {
|
||||||
PortalUser user = portalUserRepository.findPortalUserByEmailAddr(username)
|
PortalUser user = portalUserRepository.findPortalUserByEmailAddr(normalizedUsername)
|
||||||
.orElseThrow(() -> new UserNotFoundException(username));
|
.orElseThrow(() -> new UserNotFoundException(normalizedUsername));
|
||||||
|
|
||||||
user.setLoginFailureCount(user.getLoginFailureCount() + 1);
|
user.setLoginFailureCount(user.getLoginFailureCount() + 1);
|
||||||
if (user.getLoginFailureCount() >= 5) {
|
if (user.getLoginFailureCount() >= 5) {
|
||||||
|
|||||||
+3
-1
@@ -46,7 +46,9 @@ public class PortalAuthenticationSuccessHandler implements AuthenticationSuccess
|
|||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
|
||||||
Authentication authentication) throws IOException, ServletException {
|
Authentication authentication) throws IOException, ServletException {
|
||||||
String username = request.getParameter("id");
|
String username = request.getParameter("id");
|
||||||
PortalUser user = portalUserRepository.findPortalUserByEmailAddr(username).orElse(null);
|
// 이메일 소문자 변환 적용
|
||||||
|
String normalizedUsername = username != null ? username.toLowerCase() : null;
|
||||||
|
PortalUser user = portalUserRepository.findPortalUserByEmailAddr(normalizedUsername).orElse(null);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
response.sendRedirect(request.getContextPath() + "/login?error=true");
|
response.sendRedirect(request.getContextPath() + "/login?error=true");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -160,6 +160,9 @@
|
|||||||
// Show loading state
|
// Show loading state
|
||||||
$('#loginLoading').addClass('active');
|
$('#loginLoading').addClass('active');
|
||||||
|
|
||||||
|
// 이메일(아이디) 소문자 변환 적용
|
||||||
|
form.id.value = form.id.value.toLowerCase();
|
||||||
|
|
||||||
if ($('#checkId').is(':checked')) {
|
if ($('#checkId').is(':checked')) {
|
||||||
setCookie('saveid', $('#id').val(), new Date(new Date().getTime() + 1000 * 3600 * 24 * 30));
|
setCookie('saveid', $('#id').val(), new Date(new Date().getTime() + 1000 * 3600 * 24 * 30));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -39,10 +39,10 @@
|
|||||||
</body>
|
</body>
|
||||||
<th:block>
|
<th:block>
|
||||||
<script th:fragment="commonUserInfoScript" th:inline="javascript">
|
<script th:fragment="commonUserInfoScript" th:inline="javascript">
|
||||||
// 이메일 조합 함수
|
// 이메일 조합 함수 (소문자 변환 적용)
|
||||||
function combineEmail() {
|
function combineEmail() {
|
||||||
let emailId = $('#userId').val();
|
let emailId = $('#userId').val().toLowerCase();
|
||||||
let domain = $('#domain').val();
|
let domain = $('#domain').val().toLowerCase();
|
||||||
let combined = emailId + '@' + domain;
|
let combined = emailId + '@' + domain;
|
||||||
$('#loginId').val(combined);
|
$('#loginId').val(combined);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user