From 40578b2407b8299cf429af78b14966c129f62066 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 14 Mar 2018 20:17:33 +0900 Subject: [PATCH] tot service modify --- .../module/member/service/MemberTotpService.java | 5 +++-- .../module/member/service/MemberTotpServiceTest.java | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java index fc8602e..0ff2d0f 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberTotpService.java @@ -23,7 +23,7 @@ public class MemberTotpService { public void regist(Member member, String secretCode, String code) throws Exception { - if (null == member || 0 < member.getId()) { + if (null == member || 0 >= member.getId()) { throw new Exception("Not Null Member ID"); } @@ -59,7 +59,8 @@ public class MemberTotpService { public boolean checkCode(String secretCode, String code) throws Exception { GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(); - boolean isCheck = googleAuthenticator.authorize(secretCode, Integer.valueOf(code)); + int codeInt = Integer.parseInt(code); + boolean isCheck = googleAuthenticator.authorize(secretCode, codeInt); if (!isCheck) { throw new Exception("Invalid Code"); diff --git a/src/test/java/com/loafle/overflow/module/member/service/MemberTotpServiceTest.java b/src/test/java/com/loafle/overflow/module/member/service/MemberTotpServiceTest.java index 0a2c094..ebc242c 100644 --- a/src/test/java/com/loafle/overflow/module/member/service/MemberTotpServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/member/service/MemberTotpServiceTest.java @@ -11,6 +11,8 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.Map; + import static org.junit.Assert.*; /** @@ -46,7 +48,7 @@ public class MemberTotpServiceTest { MemberTotp totp = new MemberTotp(); totp.setSecretCode("PN44SRPS5QCGCJNS"); - boolean isCheck = this.totpService.checkCode(totp, "125073"); + boolean isCheck = this.totpService.checkCode("PN44SRPS5QCGCJNS", "125073"); System.out.println(isCheck); @@ -57,10 +59,10 @@ public class MemberTotpServiceTest { Member m = new Member(2); m.setEmail("geekdev@naver.com"); - MemberTotp totp = this.totpService.createTotp(m); + Map totp = this.totpService.createTotp(m ); - System.out.println(totp.getSecretCode()); - System.out.println(totp.getOtpAuth()); + System.out.println(totp.get("key")); + System.out.println(totp.get("uri")); } } \ No newline at end of file