Exceptions of MemberService has been added.

This commit is contained in:
crusader 2017-08-14 12:10:56 +09:00
parent cd512a38a4
commit a07d063be1
6 changed files with 34 additions and 4 deletions

View File

@ -0,0 +1,4 @@
package com.loafle.overflow.commons.exception;
public class OverflowException extends Exception {
}

View File

@ -0,0 +1,6 @@
package com.loafle.overflow.module.member.exception;
import com.loafle.overflow.commons.exception.OverflowException;
public class EmailNotConfirmedException extends OverflowException {
}

View File

@ -0,0 +1,6 @@
package com.loafle.overflow.module.member.exception;
import com.loafle.overflow.commons.exception.OverflowException;
public class SignInIdNotExistException extends OverflowException {
}

View File

@ -0,0 +1,6 @@
package com.loafle.overflow.module.member.exception;
import com.loafle.overflow.commons.exception.OverflowException;
public class SignInPwNotExactException extends OverflowException {
}

View File

@ -1,6 +1,9 @@
package com.loafle.overflow.module.member.service;
import com.loafle.overflow.module.member.dao.MemberDAO;
import com.loafle.overflow.module.member.exception.EmailNotConfirmedException;
import com.loafle.overflow.module.member.exception.SignInIdNotExistException;
import com.loafle.overflow.module.member.exception.SignInPwNotExactException;
import com.loafle.overflow.module.member.model.Member;
import com.loafle.overflow.module.meta.model.MetaMemberStatus;
import org.springframework.beans.factory.annotation.Autowired;
@ -16,20 +19,22 @@ public class MemberService {
@Autowired
private MemberDAO memberDAO;
public Member signin(String signinId, String signinPw) throws Exception {
public Member signin(String signinId, String signinPw) throws SignInIdNotExistException, EmailNotConfirmedException, SignInPwNotExactException {
Member m = this.memberDAO.findByEmail(signinId);
if ( null == m ) {
return m;
throw new SignInIdNotExistException();
}
if ( m.getStatus().getId() == 1 ) {
throw new Exception("Email Auth Confirm Check");
throw new EmailNotConfirmedException();
}
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
Boolean match = passwordEncoder.matches(signinPw, m.getPw());
if(!match) return null;
if(!match) {
throw new SignInPwNotExactException();
}
return m;
}

View File

@ -88,6 +88,9 @@ public class ServiceProxy {
} catch (IllegalAccessException e) {
e.printStackTrace();
responseObserver.onError(e);
} catch (Exception e) {
e.printStackTrace();
responseObserver.onError(e);
}