From 1b81edaeaf53e16b676bdfbeb94bdeeae8a6cbf4 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 23 Aug 2017 16:26:42 +0900 Subject: [PATCH] pw exception --- .../exception/EqualsOldPasswordException.java | 16 ++++++++++++++ .../module/member/service/MemberService.java | 21 ++++++++++++------- 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/loafle/overflow/module/member/exception/EqualsOldPasswordException.java diff --git a/src/main/java/com/loafle/overflow/module/member/exception/EqualsOldPasswordException.java b/src/main/java/com/loafle/overflow/module/member/exception/EqualsOldPasswordException.java new file mode 100644 index 0000000..4258c20 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/member/exception/EqualsOldPasswordException.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.module.member.exception; + +import com.loafle.overflow.commons.exception.OverflowRuntimeException; + +/** + * Created by geek on 17. 8. 23. + */ +public class EqualsOldPasswordException extends OverflowRuntimeException { + public EqualsOldPasswordException() { + super(); + } + + public EqualsOldPasswordException(String message) { + super(message); + } +} 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 c8ab4c3..fa7ab4d 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 @@ -2,10 +2,7 @@ package com.loafle.overflow.module.member.service; import com.loafle.overflow.module.email.service.EmailAuthService; import com.loafle.overflow.module.member.dao.MemberDAO; -import com.loafle.overflow.module.member.exception.EmailNotConfirmedException; -import com.loafle.overflow.module.member.exception.JoinedEmailException; -import com.loafle.overflow.module.member.exception.SignInIdNotExistException; -import com.loafle.overflow.module.member.exception.SignInPwNotMatchException; +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; @@ -70,21 +67,29 @@ public class MemberService { // Todo websocket session remove } - public Member modify(Member member) { + public Member modify(Member member, String pw) { 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) { - throw new SignInPwNotMatchException(); + if(match) { + throw new EqualsOldPasswordException(); } return this.memberDAO.save(member); } public Member read(long memberId) { - return this.memberDAO.findOne(memberId); + if (memberId <= 0) { + // Todo MemberId null Exception + } + + Member resMember = this.memberDAO.findOne(memberId); + + + return resMember; } public void withdrawal(Member member) {