procompiler / developer-village

😈 개발자를 위한 소셜 네트워크 서비스 🌐
34 stars 7 forks source link

아이디/비밀번호 찾기 & 비밀번호 변경 기능 추가 #30

Closed hayeon17kim closed 3 years ago

hayeon17kim commented 3 years ago

Description

image image image

비밀번호를 잊었을 때 이메일을 이용해 비밀번호를 찾고, 이를 변경할 수 있는 기능을 추가한다.

Progress

Jiyoun-Yoo commented 3 years ago

아이디 찾기 기능 구현

스크린샷 2020-12-27 오후 11 44 32

Commit

Jiyoun-Yoo commented 3 years ago

비밀번호 찾기 기능

Commit

추후 보완할 것

Jiyoun-Yoo commented 3 years ago

비밀번호 변경 기능

Commit

추후 보완할 것

의문점

searchPwdResult.jsp

      <form id="updatePwd" action="updatePwd" method="post">
        <input id='userNo' type='hidden' name='userNo' value='${param.userNo}'>
        <div class="mb-3 row">
          <label for="password" class='form-label col-sm-2 col-form-label'>비밀번호</label>
          <div class="col-sm-10">
            <input id='inputPassword' type='password' class="form-control" name='password' placeholder="password">
          </div>
        </div>

        <div class="d-grid gap-2">
          <button class="btn btn-primary">비밀번호 재설정</button>
        </div>
      </form>

AuthController.java

  @PostMapping("updatePwd")
  public void updatePwd(int userNo, String password) throws Exception {
    userService.updatePwd(userNo, password);
  }

searchPwdResult.jsp

      <form id="updatePwd" action="searchPwdResult-send" method="post">
        <input id='userNo' type='hidden' name='userNo' value='${param.userNo}'>
        <div class="mb-3 row">
          <label for="password" class='form-label col-sm-2 col-form-label'>비밀번호</label>
          <div class="col-sm-10">
            <input id='inputPassword' type='password' class="form-control" name='password' placeholder="password">
          </div>
        </div>

        <div class="d-grid gap-2">
          <button class="btn btn-primary">비밀번호 재설정</button>
        </div>
      </form>

AuthController.java

  @PostMapping("searchPwdResult-send")
  public void searchPwdResult(int userNo, String password) throws Exception {
    userService.updatePwd(userNo, password);
    return "redirect:login";
  }
Jiyoun-Yoo commented 3 years ago
Jiyoun-Yoo commented 3 years ago

수정사항

      <form id="updatePwdForm" action="updatePwd" method="post">
        <input id='userNo' type='hidden' name='userNo' value='${param.userNo}'>
        <div class="mb-3 row">
          <label for="password" class='form-label col-sm-2 col-form-label'>비밀번호</label>
          <div class="col-sm-10">
            <input id='inputPassword' type='password' class="form-control" name='password' placeholder="password">
          </div>
        </div>

            <div class="mb-3 row">
              <label for="passwordConfirm" class='form-label col-sm-2 col-form-label'>비밀번호 확인</label>
                <div class="col-sm-10">
                  <input id="passwordConfirm" type='password' class="form-control" name='passwordConfirm' 
                         placeholder="위의 비밀번호와 동일하게 입력">
                </div>
            </div>

        <div class="d-grid gap-2">
          <button class="btn btn-primary">비밀번호 재설정</button>
        </div>
      </form>

<script>
document.querySelector("#updatePwdForm").onsubmit = () => {
  var inputPassword = document.querySelector("#inputPassword");
  var passwordConfirm = document.querySelector("#passwordConfirm");

  if (inputPassword.value.length < 8) {
    alert("비밀번호를 8자 이상 입력하세요!");
    return false;
  } else if (inputPassword.value != passwordConfirm.value) {
    alert("비밀번호가 일치하지 않습니다.");
    return false;
  }
};
</script>