Skip to content

Commit

Permalink
[FIX]#8 코드 리팩터링및 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 committed Aug 28, 2023
1 parent b49ef5d commit 2215354
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,14 @@ public User signUp(SignUpReq signUpReq) {


public String signIn(SignInReq signInReq) {
// 인증 과정
// Optional<User> byEmail = userRepository.findByEmail(signInReq.getEmail());
// System.out.println("byEmail = " + byEmail);
// if (!BCrypt.checkpw(password, user.getPassword())) {
//
// return null;
// }

// 이메일을 통해 사용자 정보 조회
Optional<User> byEmail = userRepository.findByEmail(signInReq.getEmail());

if (byEmail.isPresent()) {
User user = byEmail.get();
// boolean isPasswordCorrect = BCrypt.checkpw(signInReq.getPassword(), user.getPassword());

if (BCrypt.checkpw(signInReq.getPassword(), user.getPassword())) {
return JwtUtil.createJwt(signInReq.getEmail(), secret_key, expiredMs);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public ResponseEntity<BaseResponse<User>> signUp(@Valid @RequestBody SignUpReq s
public ResponseEntity<BaseResponse<String>> signIn(@Valid @RequestBody SignInReq signInReq) {
try {
String token = userService.signIn(signInReq);
System.out.println("token = " + token);

if (token != null) {
return ResponseEntity.ok(BaseResponse.success(SuccessCode.SIGNIN_SUCCESS, token));
} else {
Expand All @@ -56,6 +58,10 @@ public ResponseEntity<BaseResponse<String>> signIn(@Valid @RequestBody SignInReq
// return ResponseEntity.ok(BaseResponse.success(SuccessCode.SIGNIN_SUCCESS, userService.login("이재혁", "")));
}





// 테스트용 인가 글쓰기 (삭제 예정)
@PostMapping("/write")
public ResponseEntity<String> writeReview(Authentication authentication) {
Expand Down

0 comments on commit 2215354

Please sign in to comment.