diff --git a/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java b/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java index 2357ee4..1b00777 100644 --- a/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java +++ b/src/main/java/com/loafle/overflow/module/email/service/EmailAuthService.java @@ -132,6 +132,34 @@ public class EmailAuthService { return this.emailAuthDAO.save(emailAuth); } + public EmailAuth sendEmailResetPassword(Member member) throws UnsupportedEncodingException, MailException { + EmailAuth auth = new EmailAuth(); + auth.setMember(member); + // Todo AuthKey Generation + + String en = emailSender.encrypt(member.getEmail()); + auth.setEmailAuthKey(en); + + String encode = URLEncoder.encode(en, "UTF-8"); + +// System.out.println("encode = [" + encode + "]"); + Mail mail = new Mail(); + mail.setMailTo(member.getEmail()); + mail.setMailSubject("Reset Password Email"); + mail.setMailContent("http://127.0.0.1:9091/#/account/reset_password?key="+ encode +"\r\nConfirm Email"); + Map model = new HashMap<>(); + model.put("firstName", auth.getMember().getName()); + model.put("lastName", auth.getMember().getCompanyName()); + model.put("location", "Seoul"); + model.put("signature", "www.loafle.com"); + + mail.setModel(model); + emailSender.sendSimpleEmail(mail); + + this.emailAuthDAO.save(auth); + + return auth; + } } 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 827499a..3c73ebb 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 @@ -122,11 +122,9 @@ public class MemberService { if (null == member) { throw new SignInIdNotExistException(); } - String en = this.emailSender.encrypt(email); - String encode = URLEncoder.encode(en, "UTF-8"); try { - this.emailSender.sendSimpleEmail(email,"Password Reset Email", "http://127.0.0.1:9091/#/account/reset_password?key="+ encode +"\r\nConfirm Email"); + this.emailAuthService.sendEmailResetPassword(member); } catch (MailException e) { // Todo ReSend Mail e.printStackTrace();