From 4390248c65363f1432cf122e7719ebbee43f372f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?hagjoon=28=EC=9D=B4=ED=95=99=EC=A4=80=29?= Date: Tue, 18 Oct 2022 17:37:58 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20-=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=B6=94=EA=B0=80=20=EB=93=9C=EB=A1=A0=20=EA=B4=80?= =?UTF-8?q?=EC=A0=9C=20-=20||=20->=20&&=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cstmr/controller/AcntCstmrController.java | 23 ++++++++++ .../acnt/cstmr/service/AcntCstmrService.java | 43 ++++++++++++------- .../ctr/cntrl/service/CtrCntrlService.java | 2 +- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java b/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java index 63867d6..9df1f26 100644 --- a/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java +++ b/src/main/java/com/palnet/biz/api/acnt/cstmr/controller/AcntCstmrController.java @@ -121,6 +121,29 @@ public class AcntCstmrController { return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); } + + @PostMapping(value = "/profile/pwcheck/{userPswd}") + @ApiOperation(value = "회원 기존 패스워드 확인") + @Tag(name = "회원관리", description = "회원 관련 API") + public ResponseEntity extendpsw(@PathVariable String userPswd){ + Map resultMap = new HashMap(); + try { + PtyCstmrBas result = service.extendpsw(userPswd); + resultMap.put("result", result); + + } catch (CustomException e) { + log.error("IGNOE : {}", e); + resultMap.put("result", false); + resultMap.put("errorCode", e.getErrorCode()); + resultMap.put("errorMessage", e.getMessage()); + return ResponseEntity.ok().body(new SuccessResponse(resultMap)); + } catch (Exception e) { + log.error("IGONE : {}", e); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ErrorResponse("Server Error", "-1")); + } + + return ResponseEntity.ok().body(new SuccessResponse<>(resultMap)); + } @PutMapping(value = "/profile/update") @ApiOperation(value = "회원 정보 변경 (이메일,핸드폰)") diff --git a/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java b/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java index 4203edc..b2df348 100644 --- a/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java +++ b/src/main/java/com/palnet/biz/api/acnt/cstmr/service/AcntCstmrService.java @@ -13,6 +13,7 @@ import com.palnet.biz.api.acnt.cstmr.model.AcntCstmrEmModel; import com.palnet.biz.api.acnt.cstmr.model.AcntCstmrGroupModel; import com.palnet.biz.api.acnt.cstmr.model.AcntCstmrPwModel; +import com.palnet.comn.code.RSErrorCode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -221,22 +222,10 @@ public class AcntCstmrService { public PtyCstmrBas updatepas(AcntCstmrPwModel rq) { // 1. 토큰 유저 정보 불러오기 Integer userId = jwtTokenUtil.getCstmrSnoByToken(); - + // 2. DB의 유저정보 조회 -// AcntCstmrRqModel result = query.findpassword(userId); PtyCstmrBas userEntity = ptyCstmrBasRepository.findById(userId).orElse(null); - - // 3. RQ의 유저 패스워드를 암호화 처리 - rq.setUserPswd(EncryptUtils.sha256Encrypt(rq.getUserPswd())); - - // 4. RQ의 암호화한 패스워드와 DB에서 조회한 유저의 패스워드랑 비교 - if(!rq.getUserPswd().equals(userEntity.getUserPswd())) { - log.info("RQ 비밀번호 : {}, DB 비밀번호 : {}", rq.getUserPswd(), userEntity.getUserPswd()); - // 4.e 일치하지 않으면 예외처리 (패스워드 불일치) - throw new CustomException(ErrorCode.FAIL); // 임시,, 수정해야함 - } - // 5. 새로운 비밀번호 검증 if(!rq.getNewPswd().equals(rq.getNewPswdConfirm())) { // 5.e 새로운 비밀번호 일치하지 않으면 예외처리 @@ -246,8 +235,8 @@ public class AcntCstmrService { // 6. 새로운 패스워드 암호화 String encryptNewPwd = EncryptUtils.sha256Encrypt(rq.getNewPswd()); - // 7. 유저 정보 저장 - userEntity.setUserPswd(encryptNewPwd); + // 7. 유저 정보 저장 + userEntity.setUserPswd(encryptNewPwd); userEntity.setPswdUpdtDt(DateUtils.nowDate()); PtyCstmrBas updateUserEntity = ptyCstmrBasRepository.save(userEntity); @@ -255,6 +244,30 @@ public class AcntCstmrService { return updateUserEntity; } + public PtyCstmrBas extendpsw(String userPswd){ + // 1. 토큰 유저 정보 불러오기 + Integer userId = jwtTokenUtil.getCstmrSnoByToken(); + + // 2. DB의 유저정보 조회 +// AcntCstmrRqModel result = query.findpassword(userId); + PtyCstmrBas userEntity = ptyCstmrBasRepository.findById(userId).orElse(null); + + // 3. RQ의 유저 패스워드를 암호화 처리 + userPswd = EncryptUtils.sha256Encrypt(userPswd); + + // 4. RQ의 암호화한 패스워드와 DB에서 조회한 유저의 패스워드랑 비교 + if(!userPswd.equals(userEntity.getUserPswd())) { + log.info("USERPSWD 비밀번호 : {}, DB 비밀번호 : {}", userPswd, userEntity.getUserPswd()); + // 4.e 일치하지 않으면 예외처리 (패스워드 불일치) + throw new CustomException(ErrorCode.FAIL); // 임시,, 수정해야함 + } + userEntity.setUserPswd(userPswd); + + PtyCstmrBas extendpswEntity = ptyCstmrBasRepository.save(userEntity); + + return extendpswEntity; + } + public PtyCstmrDtl updateEmail(AcntCstmrEmModel rq) { Integer cstmrSno = jwtTokenUtil.getCstmrSnoByToken(); String userId = jwtTokenUtil.getUserIdByToken(); diff --git a/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java b/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java index 53f5b46..1779fbf 100644 --- a/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java +++ b/src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java @@ -134,7 +134,7 @@ public class CtrCntrlService { List areaList = query.detailArea(controlId); String stAreaNm = ""; - if (!result.getHpno().isEmpty() || result.getHpno() != null) { + if (!result.getHpno().isEmpty() && result.getHpno() != null) { result.setHpno(EncryptUtils.decrypt(result.getHpno())); }