관리자 관리 수정

This commit is contained in:
2025-12-15 10:38:26 +09:00
parent dfaa55ee49
commit 9baef15d6a
10 changed files with 75 additions and 84 deletions

View File

@@ -4,8 +4,6 @@ import com.kamco.cd.kamcoback.auth.CustomUserDetails;
import com.kamco.cd.kamcoback.auth.JwtTokenProvider;
import com.kamco.cd.kamcoback.auth.RefreshTokenService;
import com.kamco.cd.kamcoback.common.enums.StatusType;
import com.kamco.cd.kamcoback.common.enums.error.AuthErrorCode;
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
import com.kamco.cd.kamcoback.members.dto.MembersDto;
import com.kamco.cd.kamcoback.members.dto.SignInRequest;
@@ -112,17 +110,9 @@ public class AuthController {
Authentication authentication = null;
MembersDto.Member member = new MembersDto.Member();
// 비활성 상태면 임시패스워드를 비교함
if (StatusType.PENDING.getId().equals(status)) {
if (!authService.isTempPasswordValid(request)) {
throw new CustomApiException(AuthErrorCode.LOGIN_PASSWORD_MISMATCH);
}
} else {
authentication =
authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(
request.getUsername(), request.getPassword()));
}
authentication =
authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(request.getUsername(), request.getPassword()));
// PENDING 비활성 상태(새로운 패스워드 입력 해야함)
if (StatusType.PENDING.getId().equals(status)) {

View File

@@ -28,9 +28,7 @@ public class MembersDto {
private String userRole;
private String userRoleName;
private String name;
private String userId;
private String employeeNo;
private String tempPassword;
private String status;
private String statusName;
@JsonFormatDttm private ZonedDateTime createdDttm;
@@ -43,9 +41,7 @@ public class MembersDto {
UUID uuid,
String userRole,
String name,
String userId,
String employeeNo,
String tempPassword,
String status,
ZonedDateTime createdDttm,
ZonedDateTime updatedDttm,
@@ -56,9 +52,7 @@ public class MembersDto {
this.userRole = userRole;
this.userRoleName = getUserRoleName(userRole);
this.name = name;
this.userId = userId;
this.employeeNo = employeeNo;
this.tempPassword = tempPassword;
this.status = status;
this.statusName = getStatusName(status);
this.createdDttm = createdDttm;
@@ -120,14 +114,16 @@ public class MembersDto {
@Size(min = 2, max = 100)
private String name;
@Schema(description = "임시 비밀번호", example = "q!w@e#r4")
private String tempPassword;
@NotBlank
@Schema(description = "패스워드", example = "")
@Size(max = 255)
private String password;
public AddReq(String userRole, String employeeNo, String name, String tempPassword) {
public AddReq(String userRole, String employeeNo, String name, String password) {
this.userRole = userRole;
this.employeeNo = employeeNo;
this.name = name;
this.tempPassword = tempPassword;
this.password = password;
}
}
@@ -139,18 +135,18 @@ public class MembersDto {
@Size(min = 2, max = 100)
private String name;
@Schema(description = "패스워드", example = "")
@Size(max = 255)
private String tempPassword;
@Schema(description = "상태", example = "ACTIVE")
@EnumValid(enumClass = StatusType.class, message = "status는 ACTIVE, INACTIVE, DELETED 만 가능합니다.")
private String status;
public UpdateReq(String name, String tempPassword, String status) {
@Schema(description = "패스워드", example = "")
@Size(max = 255)
private String password;
public UpdateReq(String name, String status, String password) {
this.name = name;
this.tempPassword = tempPassword;
this.status = status;
this.password = password;
}
}
@@ -158,14 +154,15 @@ public class MembersDto {
@Setter
public static class InitReq {
@Schema(description = "변경 패스워드", example = "")
@Schema(description = "기존 패스워드", example = "")
@Size(max = 255)
@NotBlank
private String password;
private String oldPassword;
@Schema(description = "초기 패스워드", example = "")
@Schema(description = "신규 패스워드", example = "")
@Size(max = 255)
@NotBlank
private String tempPassword;
private String newPassword;
}
@Getter

View File

@@ -1,6 +1,5 @@
package com.kamco.cd.kamcoback.members.service;
import com.kamco.cd.kamcoback.common.enums.StatusType;
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.common.utils.CommonStringUtils;
import com.kamco.cd.kamcoback.members.dto.MembersDto;
@@ -26,7 +25,7 @@ public class AdminService {
*/
@Transactional
public Long saveMember(MembersDto.AddReq addReq) {
if (!CommonStringUtils.isValidPassword(addReq.getTempPassword())) {
if (!CommonStringUtils.isValidPassword(addReq.getPassword())) {
throw new CustomApiException("WRONG_PASSWORD", HttpStatus.BAD_REQUEST);
}
@@ -41,12 +40,6 @@ public class AdminService {
*/
@Transactional
public void updateMembers(UUID uuid, MembersDto.UpdateReq updateReq) {
if (StatusType.INACTIVE.getId().equals(updateReq.getStatus())) {
// 미사용 처리
membersCoreService.deleteMember(uuid);
} else {
// 수정
membersCoreService.updateMembers(uuid, updateReq);
}
membersCoreService.updateMembers(uuid, updateReq);
}
}

View File

@@ -37,7 +37,7 @@ public class MembersService {
@Transactional
public void resetPassword(String id, MembersDto.InitReq initReq) {
if (!CommonStringUtils.isValidPassword(initReq.getPassword())) {
if (!CommonStringUtils.isValidPassword(initReq.getNewPassword())) {
throw new CustomApiException("WRONG_PASSWORD", HttpStatus.BAD_REQUEST);
}
membersCoreService.resetPassword(id, initReq);