public bool DeleteForgetPasswordRequest(ForgetPasswordRequest forgetPasswordRequest)
 {
     if (forgetPasswordRequest == null) return false;
     _unitOfWork.ForgetPasswordRequestRepository.Delete(forgetPasswordRequest);
     _unitOfWork.Save();
     return true;
 }
Exemplo n.º 2
0
        public ActionResult ForgetPasswordRequest(ForgotPasswordRequestModel model)
        {
            if (ModelState.IsValid)
            {
               UserProfile profile = _userProfileService.GetUser(model.UserName);
                if (profile != null && !profile.LockedInInd)
                {
                   ForgetPasswordRequest req = new ForgetPasswordRequest()
                    {
                        Completed = false,
                        ExpieryDate = DateTime.Now.AddMonths(2),
                        GeneratedDate = DateTime.Now,
                        RequestKey = MD5Hashing.MD5Hash(Guid.NewGuid().ToString()),
                        UserProfileID = profile.UserProfileID
                    };
                    if (_forgetPasswordRequestService.AddForgetPasswordRequest(req))
                    {

                        string to = profile.Email;
                        string subject = "Password Change Request";
                        string link = Request.Url.Host + "/Account/ForgetPassword/?key=" + req.RequestKey;
                        string body = string.Format(@"Dear {1}
                                                            <br /><br />
                                                        A password reset request has been submitted for your DRMFSS - CTS account. If you submitted this password reset request, please follow the following link.
                                                        <br /><br />
                                                        <a href='{0}'>Please Follow this Link</a> <br />
                                                        <br /><br />
                                                        Please ignore this message if the password request was not submitted by you. This request will expire in 24 hours.
                                                        <br /><br />
                                                       Thank you,<br />
                                                       Administrator.
                                                        ", link, profile.GetFullName());

                        try
                        {
                            // Read the configuration table for smtp settings.

                           string from = _settingService.GetSettingValue("SMTP_EMAIL_FROM");
                           string smtp = _settingService.GetSettingValue("SMTP_ADDRESS");
                           int port = Convert.ToInt32(_settingService.GetSettingValue("SMTP_PORT"));
                           string userName =_settingService.GetSettingValue("SMTP_USER_NAME");
                           string password = _settingService.GetSettingValue("SMTP_PASSWORD");
                            // send the email using the utilty method in the shared dll.
                          SendMail mail = new SendMail(from, to, subject, body, null, true, smtp,userName,password, port);
                           return RedirectToAction("ConfirmPasswordChange");
                        }
                        catch (Exception e)
                        {
                            ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                        }
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                    }

                }
                else
                {
                    ViewBag.ErrorMessage = "The user name or email address you provided is not correct. Please try again.";
                }
            }
            return View("ForgetPasswordRequest", model);
        }
 public bool EditForgetPasswordRequest(ForgetPasswordRequest forgetPasswordRequest)
 {
     _unitOfWork.ForgetPasswordRequestRepository.Edit(forgetPasswordRequest);
     _unitOfWork.Save();
     return true;
 }