public ActionResult ForgotPw_step2(string Account, string Email) { if (service.AccountCheck(Account)) { if (Email != "" && Account != "") { string np = MemberMethod.GetNewPW(); string newv = service.UpdatePassword(np, Account); if (newv != null) { string tempmail = System.IO.File.ReadAllText(Server.MapPath(@"~/Areas/Members/Email/verification.html"));//讀取html UriBuilder ValidateUrl = new UriBuilder(Request.Url) { Path = Url.Action("AccountOpen", "Login", new { AuthCode = newv }) }; MemberMethod.SendEmail("Fancy忘記密碼㊙️", Email, Account, np, MemberMethod.VerificationCodeMailBody(tempmail, Account, np, ValidateUrl.ToString().Replace("%3F", "?"))); return(Json("done")); } } return(Json("fail")); } else { return(Json("fail")); } }
public bool AdminUserControl(int id, string NewPW, string guid, string tempmail, string ValidateUrl) { try { var user = db.Users.Find(id); user.UserPassword = MemberMethod.HashPw(NewPW, guid); user.GUID = guid; db.SaveChanges(); MemberMethod.SendEmail("使用者資料修改通知📝", user.Email, user.UserName, NewPW, MemberMethod.VerificationCodeMailBody(tempmail, user.UserName, NewPW, ValidateUrl.Replace("%3F", "?"))); return(true); } catch (Exception) { return(false); } }