반응형
회원 정보 수정을 하기 전이나 탈퇴하기 전에 비밀번호 확인 페이지를
재활용 하기 위해 사용했습니다.
UserController.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | @PostMapping("/userPwCheck") public String userPwCheckProc(PasswordCheckDto passwordCheckDto) { User principal = (User) session.getAttribute(Define.PRINCIPAL); User user = userService.readUserById(principal.getId()); Boolean isChecked = bCryptPasswordEncoder.matches(passwordCheckDto.getPasswordd(), principal.getPassword()); if(isChecked == false) { trhow new CustomRestfullException("비밀번호가 일치하지 않습니다.", HttpStatus.BAD_REQUEST); } else { // 타입 구분하기 .equals("") if(passwordCheckDto.getType().equals("userUpdate")) { return "redirect:/userUpdate"; } else if(passwordCheckDto.getType().equals("userWithdraw")) { return "redirect:/userWithdraw"; } } return "에러페이지 주소"; } | cs |
PasswordCheckDto
1 2 3 4 5 6 7 8 9 | @Data public class PasswordCheckDto { private String id; private String password; // 회원 정보 수정, 탈퇴 private String type; } | cs |
userPwCheck.jsp
1 | <input type="hidden" name="type" value="${type}"> | cs |
header.jsp
1 2 | <li><a href="/userPwCheck?type=userUpdate">회원 정보 수정</a> <li><a href="/userPwCheck?type=userWithdraw">탈퇴</a> | cs |
→ 주소 설계 확인
반응형
'프로그래밍 > Spring Boot 프로젝트' 카테고리의 다른 글
항공사 플랫폼 팀 프로젝트_비밀번호 변경 기능(BCrypt 라이브러리 사용) (0) | 2023.07.16 |
---|---|
항공사 플랫폼 팀 프로젝트_마이그레이션 후 쿼리문 수정 (0) | 2023.07.16 |
항공사 플랫폼 팀 프로젝트_수정 기능 AJAX 통신 (0) | 2023.07.16 |
항공사 플랫폼 팀 프로젝트_페이징 처리 (0) | 2023.07.16 |
항공사 플랫폼 팀 프로젝트_회원가입 비밀번호 확인 AJAX 통신 (0) | 2023.07.16 |