Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
67057ceed6
|
@ -6,7 +6,9 @@ import com.loafle.overflow.module.member.exception.*;
|
|||
import com.loafle.overflow.module.member.model.Member;
|
||||
import com.loafle.overflow.module.meta.model.MetaMemberStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
|
@ -21,6 +23,8 @@ public class MemberService {
|
|||
@Autowired
|
||||
private EmailAuthService emailAuthService;
|
||||
|
||||
private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
|
||||
public Member signin(String signinId, String signinPw) throws SignInIdNotExistException, EmailNotConfirmedException, SignInPwNotMatchException {
|
||||
Member m = this.memberDAO.findByEmail(signinId);
|
||||
|
||||
|
@ -32,7 +36,6 @@ public class MemberService {
|
|||
throw new EmailNotConfirmedException();
|
||||
}
|
||||
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
Boolean match = passwordEncoder.matches(signinPw, m.getPw());
|
||||
if(!match) {
|
||||
throw new SignInPwNotMatchException();
|
||||
|
@ -49,7 +52,6 @@ public class MemberService {
|
|||
throw new JoinedEmailException();
|
||||
}
|
||||
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
member.setPw(passwordEncoder.encode(pw));
|
||||
|
||||
if (member.getStatus() == null) {
|
||||
|
@ -71,7 +73,6 @@ public class MemberService {
|
|||
|
||||
Member preMember = this.memberDAO.findByEmail(member.getEmail());
|
||||
|
||||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
member.setPw(passwordEncoder.encode(pw));
|
||||
Boolean match = passwordEncoder.matches(member.getPw(), preMember.getPw());
|
||||
if(match) {
|
||||
|
@ -81,6 +82,33 @@ public class MemberService {
|
|||
return this.memberDAO.save(member);
|
||||
}
|
||||
|
||||
public Member confirmPw(String signinId, String signinPw) {
|
||||
|
||||
Member preMember = this.memberDAO.findByEmail(signinId);
|
||||
|
||||
String encodePw = passwordEncoder.encode(signinPw);
|
||||
Boolean match = passwordEncoder.matches(encodePw, preMember.getPw());
|
||||
|
||||
if (!match) {
|
||||
throw new SignInPwNotMatchException();
|
||||
}
|
||||
|
||||
return preMember;
|
||||
}
|
||||
|
||||
public Member forgotPassword(String signinId, String newPw) {
|
||||
Member preMember = this.memberDAO.findByEmail(signinId);
|
||||
|
||||
if (null == preMember) {
|
||||
throw new SignInIdNotExistException();
|
||||
}
|
||||
|
||||
preMember.setPw(this.passwordEncoder.encode(newPw));
|
||||
this.memberDAO.save(preMember);
|
||||
|
||||
return preMember;
|
||||
}
|
||||
|
||||
public Member read(long memberId) {
|
||||
if (memberId <= 0) {
|
||||
// Todo MemberId null Exception
|
||||
|
|
Loading…
Reference in New Issue
Block a user