diff --git a/src/main/java/com/loafle/overflow/module/member/exception/SigninOverFailedException.java b/src/main/java/com/loafle/overflow/module/member/exception/SigninOverFailedException.java new file mode 100644 index 0000000..74dd534 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/exception/SigninOverFailedException.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.module.member.exception; + +import com.loafle.overflow.commons.exception.OverflowRuntimeException; + +/** + * Created by geek on 17. 11. 23. + */ +public class SigninOverFailedException extends OverflowRuntimeException { + public SigninOverFailedException() { + super(); + } + + public SigninOverFailedException(String message) { + super(message); + } +} diff --git a/src/main/java/com/loafle/overflow/module/member/model/Member.java b/src/main/java/com/loafle/overflow/module/member/model/Member.java index 4138128..239d609 100644 --- a/src/main/java/com/loafle/overflow/module/member/model/Member.java +++ b/src/main/java/com/loafle/overflow/module/member/model/Member.java @@ -21,6 +21,7 @@ public class Member { private String companyName; private Date createDate; private MetaMemberStatus status; + private int signinFailCount; public Member() { } @@ -110,5 +111,13 @@ public class Member { this.status = status; } + @Column(name = "SIGNIN_FAIL_COUNT", nullable = true, columnDefinition = "int default 0") + public int getSigninFailCount(){ + return this.signinFailCount; + } + + public void setSigninFailCount(int failCount) { + this.signinFailCount = failCount; + } } diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java index f9c8283..c96992d 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -52,7 +52,7 @@ public class MemberService { private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); - public Member signin(String signinId, String signinPw) throws SignInIdNotExistException, EmailNotConfirmedException, SignInPwNotMatchException { + public Member signin(String signinId, String signinPw) { Member m = this.memberDAO.findByEmail(signinId); if ( null == m ) { @@ -65,9 +65,18 @@ public class MemberService { Boolean match = passwordEncoder.matches(signinPw, m.getPw()); if(!match) { + if (m.getSigninFailCount() > 10) { + throw new SigninOverFailedException("Login failed 10 times"); + } + m.setSigninFailCount(m.getSigninFailCount()+1); + this.modify(m); throw new SignInPwNotMatchException(); } + m.setSigninFailCount(0); + this.modify(m); + + // Todo Signin History return m; } @@ -79,7 +88,6 @@ public class MemberService { throw new JoinedEmailException(); } - // Todo Password Check boolean checkPass = this.isPasswordStrong(pw); if (!checkPass) { @@ -147,7 +155,7 @@ public class MemberService { } member.setPw(passwordEncoder.encode(pw)); - return this.memberDAO.save(member); + return this.modify(member); } public void signout(Member member) { @@ -180,6 +188,10 @@ public class MemberService { if (member.getStatus() == null || member.getStatus().getId() < 0) { member.getStatus().setId(preMember.getStatus().getId()); } + return this.modify(member); + } + + private Member modify(Member member) { return this.memberDAO.save(member); }