Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingadonis committed Dec 7, 2023
1 parent f9fb553 commit 77c0b7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
if ((email == null) || (email.isEmpty())) {
String hashedStr = Hash.SHA256(email + System.currentTimeMillis());

session.setAttribute("hashed_str", hashedStr);
session.setAttribute("hashed_verify_str", hashedStr);

Singleton.email.sendVerifyEmail(user, hashedStr, request);

msg = "Bạn đã nhận được một email xác thực tài khoản. Vui lòng kiểm tra email!";
} else {
if (user.getEmail().equals(email)) {
String hashedStrParameter = request.getParameter("code");
String hashedStrSession = (String) session.getAttribute("hashed_str");
String hashedStrSession = (String) session.getAttribute("hashed_verify_str");

if ((hashedStrParameter != null) && (hashedStrSession != null) && (hashedStrParameter.equals(hashedStrSession))) {
user.setStatus(UserStatus.ACTIVATE);

session.setAttribute("hashed_str", null);
session.setAttribute("hashed_verify_str", null);

request.setAttribute("success", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void sendForgotPasswordEmail(User user, String code, HttpServletRequest r
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(user.getEmail()));
message.setSubject("Miu Shop, quên mật khẩu!", "UTF-8");

String forgotPasswordLink = Server.getServerLink(request) + "forgot-password?code=" + code;
String forgotPasswordLink = Server.getServerLink(request) + "forgot-change-password?email=" + user.getEmail() + "&code=" + code;

String msgStr = String.format("<html lang=\"vi\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><style>body{font-family:Arial,sans-serif;background-color:#f5f5f5;text-align:center;padding:20px}.container{max-width:600px;margin:0 auto;background-color:#fff;padding:30px;border-radius:8px;box-shadow:0 0 20px rgba(0,0,0,.1);text-align:justify;align-items:center}h1{color:#333;font-size:24px;margin-bottom:20px}p{color:#666;text-align:justify;line-height:1.6;margin-bottom:15px}.button{display:inline-block;padding:10px 20px;font-size:16px;text-align:center;text-decoration:none;color:#fff;background-color:#4caf50;border-radius:5px}</style></head><body><div class=\"container\"><h1>Miu Shop, Quên mật khẩu!</h1><p>Chào %s. Để tạo mật khẩu mới, vui lòng truy cập vào liên kết bên dưới:</p><a href=\"%s\" class=\"button\" target=\"_blank\">Quên mật khẩu</a></div></body></html>", user.getFullName(), forgotPasswordLink);

Expand Down

0 comments on commit 77c0b7d

Please sign in to comment.