member service signin method parameter modify

This commit is contained in:
geek 2017-06-30 15:47:39 +09:00
parent d05e2b1c0a
commit 3539ebb600
3 changed files with 8 additions and 7 deletions

View File

@ -11,6 +11,6 @@ import org.springframework.stereotype.Repository;
*/
@Repository
public interface MemberDAO extends JpaRepository<Member, Long> {
@Query("select m from Member m WHERE m.email = :#{#m2.email}")
Member findByEmail(@Param("m2") Member member);
@Query("select m from Member m WHERE m.email = :signinId")
Member findByEmail(@Param("signinId") String signinId);
}

View File

@ -15,8 +15,8 @@ public class MemberService {
@Autowired
private MemberDAO memberDAO;
public Member signin(Member member) throws Exception {
Member m = this.memberDAO.findByEmail(member);
public Member signin(String signinId, String signinPw) throws Exception {
Member m = this.memberDAO.findByEmail(signinId);
if ( null == m ) {
return m;
@ -27,7 +27,7 @@ public class MemberService {
}
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
Boolean match = passwordEncoder.matches(member.getPw(), m.getPw());
Boolean match = passwordEncoder.matches(signinPw, m.getPw());
if(!match) return null;
return m;

View File

@ -4,6 +4,7 @@ import com.loafle.overflow.module.member.model.Member;
import com.loafle.overflow.module.meta.model.MetaMemberStatus;
import com.loafle.overflow.spring.AppConfig;
import com.loafle.overflow.spring.JdbcConfiguration;
import com.loafle.overflow.spring.MailConfiguration;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -17,7 +18,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Ignore
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class, MailConfiguration.class})
public class MemberDAOTest {
@Autowired
@ -41,7 +42,7 @@ public class MemberDAOTest {
Member member = new Member(1);
member.setEmail("overflow@loafle.com");
Member rr = repo.findByEmail(member);
Member rr = repo.findByEmail("overflow@loafle.com");
System.out.println("rr.getCompanyName() = " + rr.getCompanyName());
}