Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[데이먼] 스프링 카페 4단계 - 로그인 구현 #151

Open
wants to merge 34 commits into
base: dukcode
Choose a base branch
from

Conversation

dukcode
Copy link

@dukcode dukcode commented Mar 28, 2022

안녕하세요! 코드리뷰를 반영해 4단계 진행과정 PR요청드립니다.

4단계 기능 요구사항

  • 로그인과 로그아웃이 기능이 정상적으로 동작한다.
  • 현재 상태가 로그인 상태이면 상단 메뉴에서 “로그아웃”, “개인정보수정”이 표시되어야 한다.
  • 현재 상태가 로그인 상태가 아니라면 상단 메뉴에서 “로그인”, “회원가입”이 표시되어야 한다.

4단계 프로그래밍 요구사항

  • Spring MVC에서 메소드의 인자로 HttpSession을 이용해서 로그인을 구현한다.
  • Spring Security와 같은 별도 라이브러리 등은 사용하지 않는다.
  • API가 아닌 템플릿 기반으로 구현한다.

4단계 추가 요구사항

개인정보 수정 기능 추가

  • 로그인한 사용자는 자신의 정보를 수정할 수 있어야 한다.
  • 이름, 이메일만 수정할 수 있으며, 사용자 아이디는 수정할 수 없다.
  • 비밀번호가 일치하는 경우에만 수정 가능하다.

Validation

  • [전체] 공백 검증

    • userId 공백 검증
    • name 공백 검증
    • password 공백 검증
    • email 공백 검증
  • [전체] 형식 검증

    • email 형식 검증
  • 가입 시

    • 가입 시 아이디 중복 검증
  • 로그인 시

    • 아이디 및 비밀번호 불일치 검증
  • 회원 정보 수정

    • 아이디 수정 여부 검증
    • 비밀번호 불일치 검증

- SignUpUserDto 클래스 추가
- UserController 에서 로그인 시 SignUpUserDto 이용 하도록 업데이트
- controller 패키지 이동
- LoginUserDto 추가
- fogin.html Thymeleaf 적용
- fogin_failed.html Thymeleaf 적용
- UserService login() 메서드 추가
- fragment.html 경로 오류 수정
- 로그인 홈 html 생성
- UserController login() 메서드 세션 적용
- HomeController 클래스 생성
- QuestionController에 있던 home() 메서드 HomeController로 이동
- home()메서드 로그인 여부에 따라 다른 view mapping
- UserController logout() 메서드 구현
- SessionConst 클래스 생성
- fragment_login.html index_login.html 삭제
- fragment.html session 유무에 따라 if문 작성
- Controller에서 index_login view mapping 삭제
- User, LoginUserDto: validation annotation 업데이트
- JDBCTemplateRepository: findByUserId(), findById() null 반환하도록 업데이트
- application.properties, errors.properties: 에러 메세지 출력을 위한 설정 업데이트
- login_failed.html: 에러 메세지 동적으로 적용(Thymeleaf)
- login_failed.html: 삭제
- login.html: 동적 error메세지 출력
- UserController: GET /users/login 시 Model에 LoginUserDto 포함
- UserController: signUpForm() 메서드 Model에 SignUpUserDto 담도록 업데이트
- UserController: signUp() 메서드 validation 추가
- errors.properties: name, email 관련 에러 메세지 추가
- form.html: 에러있을 시 동적 렌더링 추가
- SignUpUserDto와 UpdateUserDto 같으므로 UserDto로 통합
- UserController: UserDto사용 하도록 업데이트
- UserController: 회원가입 메서드 중복 아이디 검증 기능 구현
- errors.properties: 중복 아이디 가입 에러메세지 업데이트
- UserController: update 관련 함수 아이디 변경 validation 업데이트
- errors.properties: 아이디 변경 관련 에러메세지 추가
- update.html: 동적 에러메시지 적용
- 로그인 성공시 웰컴페이지로 리다이렉트 하도록 변경
- POST users/new에서 POST /users 로 변경
- POST users/{userId}/update에서 POST /user/{userId} 로 변경
- POST questions/new에서 POST /questions 로 변경
@dukcode dukcode added the review-BE Improvements or additions to documentation label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-BE Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant