-
Notifications
You must be signed in to change notification settings - Fork 12
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
feature: [회원 관리] 로그인 컴포넌트 #72
Merged
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3bf653d
refactor: CategoryParamList 명명 수정
lxxjn0 d55878f
feat: 로그인 화면 컴포넌트 작성
lxxjn0 044f06d
refactor: primary 컬러 적용
lxxjn0 5febde4
refactor: 코드 포맷팅 적용
lxxjn0 a00f0f9
refactor: h2 database 설정 변경
lxxjn0 952b08f
refactor: member 엔티티 수정
lxxjn0 5bcd650
feat: login 인수 테스트 작성
lxxjn0 c85cd99
feat: MemberService의 login 메서드 구현
lxxjn0 d1263f6
feat: MemberControllerTest, MemberAcceptanceTest 구현
lxxjn0 1acad3a
test: test 환경 설정
lxxjn0 1733032
feat: 프론트에 api 호출 메서드 적용
lxxjn0 10059d5
feat: logging 설정 파일 추가
lxxjn0 5049b8d
feat: login 버튼 클릭 시 보이는 LoginVerifyModal 구현
lxxjn0 902d005
refactor: 불필요한 주석 제거 및 생성자 접근 지정자 수정
lxxjn0 a56e8c1
refactor: 부족한 MemberServiceTest와 LoginAdviceControllerTest 작성
lxxjn0 f55879c
Merge remote-tracking branch 'origin/develop' into feature/63
lxxjn0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
back/src/main/java/sellerlee/back/config/H2ServerConfig.java
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
back/src/main/java/sellerlee/back/member/application/MemberLoginRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @author lxxjn0 | ||
*/ | ||
|
||
package sellerlee.back.member.application; | ||
|
||
public class MemberLoginRequest { | ||
private String email; | ||
private String password; | ||
|
||
protected MemberLoginRequest() { | ||
} | ||
|
||
public MemberLoginRequest(String email, String password) { | ||
this.email = email; | ||
this.password = password; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
back/src/main/java/sellerlee/back/member/application/MemberService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @author lxxjn0 | ||
*/ | ||
|
||
package sellerlee.back.member.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import sellerlee.back.member.domain.IllegalMemberLoginException; | ||
import sellerlee.back.member.domain.Member; | ||
import sellerlee.back.member.domain.MemberRepository; | ||
|
||
@Service | ||
public class MemberService { | ||
private final MemberRepository memberRepository; | ||
|
||
public MemberService(MemberRepository memberRepository) { | ||
this.memberRepository = memberRepository; | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public void login(MemberLoginRequest request) { | ||
Member findMember = memberRepository.findMemberByEmail(request.getEmail()) | ||
.orElseThrow(() -> new IllegalMemberLoginException("이메일이 일치하는 회원이 존재하지 않습니다.")); | ||
|
||
if (!findMember.verify(request.getPassword())) { | ||
throw new IllegalMemberLoginException("비밀번호가 일치하지 않습니다."); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
back/src/main/java/sellerlee/back/member/domain/IllegalMemberLoginException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @author lxxjn0 | ||
*/ | ||
|
||
package sellerlee.back.member.domain; | ||
|
||
public class IllegalMemberLoginException extends IllegalArgumentException { | ||
public IllegalMemberLoginException(String s) { | ||
super(s); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
back/src/main/java/sellerlee/back/member/domain/MemberRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* @author lxxjn0 | ||
*/ | ||
|
||
package sellerlee.back.member.domain; | ||
|
||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MemberRepository extends JpaRepository<Member, Long> { | ||
Optional<Member> findMemberByEmail(String email); | ||
} |
17 changes: 17 additions & 0 deletions
17
back/src/main/java/sellerlee/back/member/presentation/LoginAdviceController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package sellerlee.back.member.presentation; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
import sellerlee.back.member.domain.IllegalMemberLoginException; | ||
|
||
@ControllerAdvice | ||
public class LoginAdviceController { | ||
@ExceptionHandler(IllegalMemberLoginException.class) | ||
public ResponseEntity<String> handleIllegalMemberLoginException(IllegalMemberLoginException e) { | ||
return ResponseEntity | ||
.badRequest() | ||
.body(e.getMessage()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
back/src/main/java/sellerlee/back/member/presentation/MemberController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @author lxxjn0 | ||
*/ | ||
|
||
package sellerlee.back.member.presentation; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import sellerlee.back.member.application.MemberLoginRequest; | ||
import sellerlee.back.member.application.MemberService; | ||
|
||
@RestController | ||
public class MemberController { | ||
private final MemberService memberService; | ||
|
||
public MemberController(MemberService memberService) { | ||
this.memberService = memberService; | ||
} | ||
|
||
@PostMapping("/login") | ||
public ResponseEntity<Void> login(@RequestBody MemberLoginRequest request) { | ||
memberService.login(request); | ||
|
||
return ResponseEntity | ||
.ok() | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,16 @@ spring: | |
profiles: | ||
active: local | ||
|
||
logging: | ||
level: | ||
org.hibernate.type.descriptor.sql: trace | ||
org.springframework.web: debug | ||
|
||
--- | ||
|
||
spring: | ||
profiles: local | ||
|
||
jpa: | ||
database-platform: org.hibernate.dialect.H2Dialect | ||
database: H2 | ||
|
@@ -10,16 +20,15 @@ spring: | |
hibernate: | ||
ddl-auto: create | ||
properties: | ||
hibernate.format-sql: true | ||
hibernate.format_sql: true | ||
use_sql_comments: true | ||
|
||
h2: | ||
console: | ||
enabled: true | ||
|
||
datasource: | ||
url: jdbc:h2:mem:testdb;IFEXISTS=FALSE; | ||
url: jdbc:h2:tcp://localhost/${user.dir}/test;IFEXISTS=FALSE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
username: sa | ||
password: | ||
driver-class-name: org.h2.Driver | ||
|
||
logging: | ||
level: | ||
org.hibernate.type.descriptor.sql: trace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,13 @@ | |
* @author kouz95 | ||
*/ | ||
|
||
insert into member (member_id) | ||
values (1); | ||
insert into member (member_id, email, password, score) | ||
values (1, 'sellerlee@gmail.com', '1234', 4.5), | ||
(2, 'lxxjn0@gmail.com', '0000', 5.0); | ||
|
||
insert into article (article_id, category, contents, price, title, member_id) | ||
values (1, 'TEST', 'test contents1', 1234, 'test title1', 1); | ||
|
||
insert into article (article_id, category, contents, price, title, member_id) | ||
values (2, 'TEST', 'test contents2', 5678, 'test title2', 1); | ||
values (1, 'TEST', 'test contents1', 1234, 'test title1', 1), | ||
(2, 'TEST', 'test contents2', 5678, 'test title2', 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
insert into tag (article_id, name) | ||
values (1, 'test tag1'), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엔티티가 아니라면 굳이 no-arg constructor를 public이나 protected로 만들지 않아도 됩니다.
엔티티의 경우 JPA에서 리플렉션을 사용하는데 public으로 열기 싫어서 protected로 했던 것이고,
이 경우엔 기본 생성자를 막는 용도로
private
이 더 적절해보여요.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request의 경우는 따로 리플랙션으로 값을 저장하는 것이 아닌가요?? 그 부분을 잘 몰라서 이런 방식으로 했는데 상관없으면 private로 바꾸겠습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request dto엔 jpa가 관여하지 않죠. 또한 리플렉션을 통해 객체를 만들어낼 일도 없습니다.
따라서 본인을 포함한 일반적인 사용자(개발자)들이 사용하지 않도록 private으로 변경하는 것이 좋을것같아요.