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

[BE] 회원가입 중복 확인 로그인 개인정보 조회 #62

Closed
wants to merge 167 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
a527714
Add View with storyboard and set constraint
delmaSong Mar 22, 2020
ec8b54e
Add ViewController and constraint iDTextField
delmaSong Mar 22, 2020
b484814
Feat: Change border color of textField with a regular password expres…
delmaSong Mar 22, 2020
0aa3fad
Feat: Confirm password match
delmaSong Mar 22, 2020
3177977
Add assist labels
delmaSong Mar 22, 2020
7374252
Feat: Judge ID is Valid
delmaSong Mar 22, 2020
dd60c71
Feat: Judge Password is Valid
delmaSong Mar 22, 2020
e3b2e0b
Delete unuse code
delmaSong Mar 22, 2020
596e799
Feat: Judge password is correspond
delmaSong Mar 22, 2020
7e24025
Add: constraint related NameTextField
delmaSong Mar 22, 2020
96afac9
.
delmaSong Mar 23, 2020
0234448
Add: 화면 이동시 제약조건 추가
delmaSong Mar 23, 2020
8708346
Removed file that shouldn't be tracked
delmaSong Mar 23, 2020
2f6ca60
Add: DatePicker pop when press birthDateTextField
delmaSong Mar 23, 2020
b86e3e8
Add: 생년월일에 DatePicker로 날짜 선택 기능
delmaSong Mar 23, 2020
ed6e2e3
Add: Segmented Control로 성별 선택 기능
delmaSong Mar 23, 2020
4b61e3c
Feat. 회원가입 페이지 html markup
seungdeng17 Mar 23, 2020
edc9b32
Feat. 회원가입 페이지 css style
seungdeng17 Mar 23, 2020
3e9db3b
Add: emailTextField와 유효성 검증 기능
delmaSong Mar 23, 2020
8e1c59b
Add: phoneNumberTextField와 유효성 검증 기능
delmaSong Mar 23, 2020
aa573ac
Add: 다음 버튼 누른 경우, 개인정보 동의 화면 표시
delmaSong Mar 23, 2020
54d6c29
Delete: 안쓰는 주석코드 삭제
delmaSong Mar 23, 2020
9f8cbfa
Merge pull request #14 from codesquad-memeber-2020/client/feature/htm…
seungdeng17 Mar 23, 2020
b88d065
Simplify: 변수에 접근제한자 추가
delmaSong Mar 24, 2020
c42d674
Update: Api 문서 링크 추가
moonelysian Mar 23, 2020
6192521
Init: BE project
moonelysian Mar 23, 2020
2cd3817
Init : BE Project Setting
Hyune-c Mar 23, 2020
d347b16
Update .gitignore
delmaSong Mar 23, 2020
5289c36
Delete unuse code and update gitignore
delmaSong Mar 23, 2020
50fb895
Update readme.md
delmaSong Mar 23, 2020
e8ae29f
Add: User 생성
moonelysian Mar 23, 2020
e017496
Add: User id not null 옵션 추가
moonelysian Mar 23, 2020
b224be7
Add: User 생상 함수 추가
moonelysian Mar 23, 2020
f09cf63
Add: Exception handler 추가
moonelysian Mar 23, 2020
9216e38
Deploy: 헤로쿠 배포
moonelysian Mar 24, 2020
0c00bd4
Revert "Deploy: 헤로쿠 배포"
moonelysian Mar 24, 2020
080cb79
Deploy: 헤로쿠 배포 연습
moonelysian Mar 24, 2020
f2e28ff
Feature: 로그인
moonelysian Mar 24, 2020
fcf5f69
Feature: findByUserId 쿼리 생성
moonelysian Mar 24, 2020
429d8ba
Feature: ExceptionHandler 생성
moonelysian Mar 24, 2020
b029fb8
Feature: 사용자 id, password 유효성 검증
moonelysian Mar 24, 2020
7f57c44
Remove: @ResponseBody
moonelysian Mar 24, 2020
1d2cbec
Feat. 공통 유틸, 회원가입 유틸 추가
seungdeng17 Mar 24, 2020
4fd0194
Feat. user id, password 유효성 검증 (user id 중복 검증 필요 됨)
seungdeng17 Mar 24, 2020
82e7a8d
Feat. user 생년월일, 이메일, 휴대전화 유효성 검증
seungdeng17 Mar 24, 2020
9241bdf
Feat. user 관심사 추가 기능 구현 유효성 검증
seungdeng17 Mar 24, 2020
965b8a6
Feat. 약관창 내부 이벤트 콜백 함수 구현
seungdeng17 Mar 24, 2020
8ab8e75
Feat. 초기화 버튼 기능 구현
seungdeng17 Mar 24, 2020
b250552
Update: response 형식 맞춰주기
moonelysian Mar 24, 2020
b19dc23
refactor : User toString() 추가
Hyune-c Mar 24, 2020
15fa6db
Feature: 아이디 이메일 번호 중복 검사
moonelysian Mar 24, 2020
cb203dd
Add: Exception 종류 추가
moonelysian Mar 24, 2020
ad99b02
Refector. 이벤트 추가 로직 리팩토링
seungdeng17 Mar 24, 2020
0258dbe
Refector. 매직넘버 constant.js에 상수화 시킴
seungdeng17 Mar 24, 2020
b79260e
Merge pull request #22 from codesquad-memeber-2020/server/feature/login
moonelysian Mar 24, 2020
3b70223
Merge pull request #25 from codesquad-memeber-2020/server/feature/dup…
moonelysian Mar 24, 2020
28fc6ae
Merge branch 'dev' of https://github.com/codesquad-memeber-2020/signu…
Hyune-c Mar 24, 2020
ee062ae
Refactor: 커스텀 id 텍스트 필드 생성 및 분리
delmaSong Mar 24, 2020
9e552c5
fix : userId 정규식 버그 수정
Hyune-c Mar 24, 2020
de55678
feat : User 가입 구현
Hyune-c Mar 24, 2020
b1c924e
Merge pull request #28 from codesquad-memeber-2020/server/feature/join
Hyune-c Mar 24, 2020
75b8d89
Refactor: 커스텀 password 텍스트 필드 생성 및 뷰컨트롤러의 코드 분리
delmaSong Mar 24, 2020
1909d17
Revert "input 검증 & 회원 가입"
Hyune-c Mar 24, 2020
9bb0601
Merge pull request #29 from codesquad-memeber-2020/revert-28-server/f…
Hyune-c Mar 24, 2020
9498a50
Revert "Revert "input 검증 & 회원 가입""
Hyune-c Mar 24, 2020
986c43b
Feat. 입력된 form data를 request에 보낼 json 형태로 치환하는 기능 추가
seungdeng17 Mar 25, 2020
c1f7c9d
Refector. PR 피드백 내용 리팩토링
seungdeng17 Mar 25, 2020
dce3962
Refector. 피드백 내용 리팩토링
seungdeng17 Mar 25, 2020
cbfa738
Feat. url 추가 - id 중복 검증을 위한 테스트 api, 회원가입 api
seungdeng17 Mar 25, 2020
edb8a50
Merge pull request #30 from codesquad-memeber-2020/revert-29-revert-2…
Hyune-c Mar 25, 2020
c2afc79
Merge pull request #26 from codesquad-memeber-2020/client/feature/sig…
seungdeng17 Mar 25, 2020
86acde0
refactor : 유효성 검증간 null 체크 추가
Hyune-c Mar 25, 2020
c7d50cf
test : 유효성 검증 테스트 케이스 작성
Hyune-c Mar 25, 2020
f845aea
Feat. 가입하기 버튼 click 이벤트 추가
seungdeng17 Mar 25, 2020
e84724d
Feat. 가입하기 버튼 클릭시 서버에 json data request
seungdeng17 Mar 25, 2020
e8e4a4e
refactor : 관심사 검증 로직 추가
Hyune-c Mar 25, 2020
4435c12
Fix. 초기화 click 이벤트 시 약관 동의 버튼 비활성화, 약관 팝업창 뜰 때 마다 스크롤 위치 초기화
seungdeng17 Mar 25, 2020
08a4289
refactor : user validation 로직 개선
Hyune-c Mar 25, 2020
4b109d1
test : user validation 테스트
Hyune-c Mar 25, 2020
94118ad
Merge pull request #34 from codesquad-memeber-2020/server/feature/inp…
Hyune-c Mar 25, 2020
e96ff41
refactor : USER DB constraint 변경
Hyune-c Mar 25, 2020
d2474cc
refactor : 회원가입 로직 변경
Hyune-c Mar 25, 2020
13fcdf0
Fix. 생년월일 유효하지 않은 값이 들어와도 error message 출력 되지 않는 부분, 필요 이상으로 반환값을 주는 …
seungdeng17 Mar 25, 2020
cf32fdc
Add. 로그인, 메인 페이지에 대한 html, css 생성
seungdeng17 Mar 25, 2020
3a614bc
Merge pull request #36 from codesquad-memeber-2020/client/feature/join
seungdeng17 Mar 25, 2020
b61bb81
Refactor: 커스텀 텍스트필드 생성 및 뷰컨트롤러의 코드 분리 및 노티피케이션 추가
delmaSong Mar 25, 2020
23ab6d1
Refactor: 모호한 변수명 변경
delmaSong Mar 25, 2020
8fbdd4c
Removed file that shouldn't be tracked
delmaSong Mar 23, 2020
08df9e9
Merge branch 'mobile/feature/view-feedback' into mobile/feature/view
delmaSong Mar 25, 2020
f4ee952
Add: untracked 파일 추가
delmaSong Mar 25, 2020
5f0fb40
Merge branch 'dev' into mobile/feature/view
delmaSong Mar 25, 2020
25d3bcd
Feat. 로그인, 메인 페이지 html 구조 구현 전 임시 커밋
seungdeng17 Mar 25, 2020
d78daf4
Remove: 불필요한 파일 삭제
moonelysian Mar 25, 2020
fd1dc25
refactor : review 에서 나온 점 개선
Hyune-c Mar 25, 2020
c914786
refactor : review 에서 나온 점 개선
Hyune-c Mar 25, 2020
9788578
Merge pull request #35 from codesquad-memeber-2020/server/feature/join
moonelysian Mar 25, 2020
bd97020
Merge branch 'master' into dev
moonelysian Mar 25, 2020
ac1cc31
Fix: 로그인 세션 추가 안되던 것 수정
moonelysian Mar 26, 2020
8834e9e
Merge pull request #45 from codesquad-memeber-2020/server/fix/login
Hyune-c Mar 26, 2020
215c7c3
Feat. 가입하기 버튼 클릭시 status code에 따라 메인페이지로 이동하게 함
seungdeng17 Mar 26, 2020
64a2328
Test. 정상적인 커밋푸시를 위한 임시 커밋
seungdeng17 Mar 26, 2020
4e9f622
Merge pull request #1 from codesquad-memeber-2020/mobile/feature/view
delmaSong Mar 26, 2020
4ef1f5b
Merge branch 'dev' into mobile/feature/userInfo
delmaSong Mar 26, 2020
eee260f
Merge branch 'mobile/feature/userInfo' into dev
delmaSong Mar 26, 2020
6301b43
fix : Project Setting 추가
Hyune-c Mar 26, 2020
5f3e670
Merge branch 'dev' of https://github.com/codesquad-memeber-2020/signu…
delmaSong Mar 26, 2020
0d2f2b4
Merge branch 'dev' of https://github.com/codesquad-memeber-2020/signu…
delmaSong Mar 26, 2020
dbf0042
Refator: 메세지 하드 코딩 빼내기
moonelysian Mar 26, 2020
efe280d
Feat. 아이디, 이메일, 휴대전화 입력 정보를 db 정보와 비교해 중복을 체크하는 기능 추가
seungdeng17 Mar 26, 2020
3b9caf6
Update. select input box가 맥에서 회색으로 보임 -> background-color 업데이트 함
seungdeng17 Mar 26, 2020
9c4342a
Fix. state massage update시 promise가 입력되는 상황의 방어코드 작성
seungdeng17 Mar 26, 2020
4162197
Fix: 번호 중복
moonelysian Mar 26, 2020
e1e5bc2
Merge pull request #50 from codesquad-memeber-2020/server/refactor/me…
Hyune-c Mar 26, 2020
4cd3652
gitignore 적용
delmaSong Mar 26, 2020
e3031a0
Add untracked file
delmaSong Mar 26, 2020
22322d3
Add: 회원정보 화면 기능 구현
delmaSong Mar 26, 2020
6e3b8d8
Merge pull request #53 from codesquad-memeber-2020/mobile/feature/use…
delmaSong Mar 26, 2020
dd795fe
feat : User info 기능 추가
Hyune-c Mar 26, 2020
f4ac2eb
refactor : DB Unique 값 추가
Hyune-c Mar 26, 2020
93af823
refactor : 코드 정리
Hyune-c Mar 26, 2020
4dde1da
Delete: 안쓰는 주석코드 삭제
delmaSong Mar 26, 2020
8a0c5b8
feat : BadRequestException 추가
Hyune-c Mar 26, 2020
8aa67f1
Add: 약관 화면에 약관 텍스트 설정 추가 및 액션시트 기능, 화면이동 기능 추가
delmaSong Mar 26, 2020
f35618b
refactor : User info 의 예외 처리
Hyune-c Mar 26, 2020
2c953b7
Add gitignore
delmaSong Mar 26, 2020
442ce9f
gitignore 적용
delmaSong Mar 26, 2020
a04fe25
Merge remote-tracking branch 'origin/dev' into mobile/feature/terms
delmaSong Mar 26, 2020
23836ae
Merge pull request #56 from codesquad-memeber-2020/mobile/feature/terms
delmaSong Mar 26, 2020
f970e4e
Modify: 폴더 구조 변경
delmaSong Mar 26, 2020
225cf4f
refactor : #54 리뷰 개선
Hyune-c Mar 26, 2020
4d0d114
Merge pull request #54 from codesquad-memeber-2020/server/feature/use…
moonelysian Mar 26, 2020
30430a2
Refator: Exception.class 들 중복 코드 제거
moonelysian Mar 26, 2020
ec95eb7
Refator: Forbidden에러 추가 및 리팩토링
moonelysian Mar 26, 2020
04b0f3c
Merge pull request #58 from codesquad-memeber-2020/server/refactor/ex…
Hyune-c Mar 26, 2020
803eec0
Feat. 로그인 기능 추가, 가입하기시 유효성 검증이 되면 입력한 아이디, 비밀번호로 로그인 request를 보냄
seungdeng17 Mar 26, 2020
0b1db66
Fix. 함수명 오타 수정 makeLoginDate -> makeLoginData
seungdeng17 Mar 26, 2020
d50718e
Add. 메인 페이지에 대한 js 파일 추가, 기능 구현은 되지 않은 상태
seungdeng17 Mar 27, 2020
31dfc84
Add: IBOutlet 바인딩 재추가 및 관심사 화면에 관심사 배열 추가
delmaSong Mar 27, 2020
5fd21c0
Update. js webpack bundle 후 적용 babel은 추후 적용 예정
seungdeng17 Mar 27, 2020
c54db8e
Add: 프론트 자원 추가
moonelysian Mar 27, 2020
66648f2
Fix: js 번들 수정
moonelysian Mar 27, 2020
ef6be90
Fix: js 복붙 잘못한거 수정
moonelysian Mar 27, 2020
a2cae34
Fix: js 번들팩 전체 수정
moonelysian Mar 27, 2020
63e5d5d
Merge pull request #61 from codesquad-memeber-2020/test/deploy
moonelysian Mar 27, 2020
743b499
Update README.md
moonelysian Mar 27, 2020
6a04a7a
Update. 서버 배포 가능한 버전으로 업데이트
seungdeng17 Mar 27, 2020
947fa1c
Merge pull request #51 from codesquad-memeber-2020/client/feature/http
seungdeng17 Mar 27, 2020
9e264d1
Fix. 배포 URL 주소 수정
seungdeng17 Mar 27, 2020
0f88fc9
Add: 관심사 추가 삭제 기능 구현
delmaSong Mar 27, 2020
f01d4b0
Add: 버튼에 이전화면,다음화면으로 이동 기능 추가
delmaSong Mar 27, 2020
2c25810
Add: 누락된 연결 추가
delmaSong Mar 27, 2020
b3a1924
Merge pull request #63 from codesquad-memeber-2020/mobile/feature/int…
delmaSong Mar 27, 2020
bba09ad
Add: 데모 영상 추가
delmaSong Mar 27, 2020
858ac06
Merge pull request #65 from codesquad-memeber-2020/mobile/feature/int…
delmaSong Mar 27, 2020
dffa368
Add: 앞에서 입력받은 정보 다음 화면으로 전달
delmaSong Mar 28, 2020
1231a9c
Add: Request Manager
delmaSong Mar 28, 2020
2d10d67
Add: UserInfo Model
delmaSong Mar 28, 2020
ce55767
Add: 관심사 적어달라는 메시지 라벨 추가
delmaSong Mar 28, 2020
bfcc073
Add: 관심사 적어달라는 메시지 라벨 추가
delmaSong Mar 28, 2020
0140c3a
Add: 버튼에 이미지 추가
delmaSong Mar 28, 2020
4fb4e71
Add: 회원가입 요청 보내기
delmaSong Mar 28, 2020
46843c9
Add: 서버 요청 코드 분리 및 회원가입 성공/실패 알럿 생성 및 화면 이동 기능
delmaSong Mar 28, 2020
64faf40
Add: 화면 흐름을 위해 버튼 및 기능 추가
delmaSong Mar 28, 2020
3fa2384
Fix: 관심사 셀 사이즈 동적 조절되도록 수정
delmaSong Mar 29, 2020
3375b0f
Modify: demo 영상 변경
delmaSong Mar 29, 2020
5940d95
Merge pull request #66 from codesquad-member-2020/mobile/feature/join
delmaSong Mar 29, 2020
ec77322
Modify: 데모 영상 변경
delmaSong Mar 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 109 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,110 @@

### macOS ###
# General
.DS_Store
*wcworkspace/xcuserdata/*
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Swift ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
.build/
# Add this line if you want to avoid checking in Xcode SPM integration.
# .swiftpm/xcode

# CocoaPods
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
# Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# Accio dependency management
Dependencies/
.accio/

# fastlane
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

<<<<<<< HEAD

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파일에 conflict mark가 그대로 묻어있네요....

iOSInjectionProject/
=======
iOSInjectionProject/
>>>>>>> origin/dev
1 change: 1 addition & 0 deletions BE/signup/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
compile 'pl.allegro.tech.boot:handlebars-spring-boot-starter:0.3.0'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
Expand Down
4 changes: 2 additions & 2 deletions BE/signup/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ public static void main(String[] args) {
log.debug("### debug SignupApplication Start");
log.trace("### trace SignupApplication Start");
}

}
21 changes: 21 additions & 0 deletions BE/signup/src/main/java/com/codesquad/signup/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.codesquad.signup;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
registry.addViewController("/main").setViewName("main");
registry.addViewController("/joinForm").setViewName("signup");
registry.addViewController("/loginForm").setViewName("login");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.codesquad.signup.controller;

import com.codesquad.signup.exception.UnauthorizedException;
import com.codesquad.signup.message.ErrorMessages;
import com.codesquad.signup.message.SuccessMessages;
import com.codesquad.signup.repository.ApiResponse;
import com.codesquad.signup.repository.User;
import com.codesquad.signup.repository.UserRepository;
import com.codesquad.signup.util.HttpSessionUtil;
import com.codesquad.signup.util.VerifyFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
public class AuthController {
static final String USER_ID = "userId";
static final String PASSWORD = "password";
Comment on lines +21 to +22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private 붙여주세요.


@Autowired
private UserRepository userRepository;

@PostMapping("/login")
public ResponseEntity<ApiResponse> login(@RequestBody Map<String, String> loginInfo, HttpSession session) {

String userId = loginInfo.get(USER_ID);
String password = loginInfo.get(PASSWORD);

if (!VerifyFormatUtil.isCorrectUserIdFormat(userId)){
throw new UnauthorizedException(ErrorMessages.FAIL_LOGIN);
}

if (!VerifyFormatUtil.isCorrectPasswordFormat(password)) {
throw new UnauthorizedException(ErrorMessages.FAIL_LOGIN);
}

User user = userRepository.findByUserId(userId)
.orElseThrow(() -> new UnauthorizedException(ErrorMessages.FAIL_LOGIN));

if (!user.isCorrectPassword(password)) {
throw new UnauthorizedException(ErrorMessages.FAIL_LOGIN);
}

session.setAttribute(HttpSessionUtil.USER_SESSION_KEY, user);

return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, SuccessMessages.SUCCESS_LOGIN), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.codesquad.signup.controller;

import com.codesquad.signup.exception.NotFoundPathException;
import com.codesquad.signup.exception.NotUniqueException;
import com.codesquad.signup.exception.WrongFormatException;
import com.codesquad.signup.message.ErrorMessages;
import com.codesquad.signup.message.SuccessMessages;
import com.codesquad.signup.repository.ApiResponse;
import com.codesquad.signup.repository.User;
import com.codesquad.signup.repository.UserRepository;
import com.codesquad.signup.util.VerifyFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("/duplicate")
public class DuplicateController {

@Autowired
private UserRepository userRepository;

@GetMapping
public Object isDuplicate(String userId, String email, String phone) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리턴타입으로 Object를 쓰는 건 자제해주세요.


if (userId != null)
return isUserIdDuplicate(userId);

if (email != null)
return isEmailDuplicate(email);

if (phone != null)
return isPhoneNumberDuplicate(phone);

return new NotFoundPathException(ErrorMessages.NOTFOUND_PATH);
}

private ResponseEntity<ApiResponse> isUserIdDuplicate(String userId) {

if (!VerifyFormatUtil.isCorrectUserIdFormat(userId)) {
throw new WrongFormatException(ErrorMessages.WRONG_FORMAT);
}

Optional<User> user = userRepository.findByUserId(userId);

if (user.isPresent())
throw new NotUniqueException(ErrorMessages.DUPLICATED_USER_ID);

return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, SuccessMessages.VALID_USER_ID), HttpStatus.OK);
}


private ResponseEntity<ApiResponse> isEmailDuplicate(@RequestParam("email") String email) {

if (!VerifyFormatUtil.isCorrectEmailFormat(email)) {
throw new WrongFormatException(ErrorMessages.WRONG_FORMAT);
}

Optional<User> user = userRepository.findByEmail(email);

if (user.isPresent())
throw new NotUniqueException(ErrorMessages.DUPLICATED_EMAIL);

return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, SuccessMessages.VALID_EMAIL), HttpStatus.OK);
}

private ResponseEntity<ApiResponse> isPhoneNumberDuplicate(@RequestParam(value = "phone") String phone) {

if (!VerifyFormatUtil.isCorrectPhoneNumberFormat(phone)) {
throw new WrongFormatException(ErrorMessages.WRONG_FORMAT);
}

Optional<User> user = userRepository.findByPhoneNumber(phone);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

단순히 전화번호 중복체크를 위해서 유저 전체를 받아오는 건 좋지 않아보이고요,
COUNT 쿼리 등을 사용하는 것으로 개선해보면 어떨까 생각이 드네요.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


if (user.isPresent())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조건문에 중괄호 { 잊지 말아주세요.

throw new NotUniqueException(ErrorMessages.DUPLICATED_PHONE);

return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, SuccessMessages.VALID_PHONE), HttpStatus.OK);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.codesquad.signup.controller;

import com.codesquad.signup.exception.ForbiddenException;
import com.codesquad.signup.exception.UserJoinFailedException;
import com.codesquad.signup.message.ErrorMessages;
import com.codesquad.signup.message.SuccessMessages;
import com.codesquad.signup.repository.ApiResponse;
import com.codesquad.signup.repository.User;
import com.codesquad.signup.repository.UserRepository;
import com.codesquad.signup.util.HttpSessionUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Slf4j
@RestController
public class UserController {

@Autowired
private UserRepository userRepository;

@PostMapping("/join")
@ResponseBody
public ResponseEntity<ApiResponse> joinUser(@RequestBody User user) {
log.debug("### joinUser : {}", user);

user.checkValidUser();

try {
User joinedUser = userRepository.save(user);
return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, joinedUser), HttpStatus.OK);
} catch (Exception e) {
throw new UserJoinFailedException(ErrorMessages.FAIL_JOIN);
}
}

@GetMapping("/user/{id}")
public ResponseEntity<ApiResponse> show(@PathVariable Long id, HttpSession session) {
log.debug("### show : {}", HttpSessionUtil.getUserFromSession(session));

User sessionedUser = HttpSessionUtil.getUserFromSession(session);

if (!sessionedUser.getId().equals(id)) {
throw new ForbiddenException(ErrorMessages.FORBIDDEN);
}

return new ResponseEntity<>(new ApiResponse(SuccessMessages.SUCCESS, sessionedUser), HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codesquad.signup.exception;

import com.codesquad.signup.message.ErrorMessages;
import com.codesquad.signup.repository.ApiResponse;

public class BaseException extends RuntimeException {
private String errorMessage;

public BaseException(String errorMessage) {
this.errorMessage = errorMessage;
}

public ApiResponse returnErrorMessage() {
return new ApiResponse(ErrorMessages.ERROR, errorMessage);
}
}
Loading