Email Service edited

This commit is contained in:
geek 2018-03-05 16:31:33 +09:00
parent 64c6252145
commit e7808ec736
2 changed files with 29 additions and 3 deletions

View File

@ -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<String, Object> 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;
}
}

View File

@ -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();