Exemple #1
0
        public ActionResult ForgotPassword(EmailVer model, FormCollection formData)
        {
            string password = Membership.GeneratePassword(12, 1);
                UserProfile prof;
                var variable = formData["Email"];

                foreach (var profile in db.UserProfiles)
                {
                    if (profile.Email == variable)
                    {
                        prof = profile;
                        var token = WebSecurity.GeneratePasswordResetToken(prof.UserName);
                        //var pwResetURL = Request.Url.GetLeftPart(UriPartial.Authority) + "/resetpassword?token=" + token;
                        WebSecurity.ResetPassword(token, password);
                        CIOS.Email.EmailSystem email = new CIOS.Email.EmailSystem();
                        email.toEmail = prof.Email;
                        email.subject = "CIOS: Password Change";
                        email.body = "Hello " + prof.UserName + ". Here's your new password: "******". Please reset your password once signed in!";
                        try
                        {
                            email.sendNewEmail();
                            return RedirectToAction("Login", "Account");

                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError("", "Error occured whilst email sendage" + e.Message);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Email address not found");
                        return View(model);
                    }
                }
                ModelState.AddModelError("", "Email address not found");
                return View(model);
        }
Exemple #2
0
 /**
    * Method Name:
    * Method Purpose:
    *
    * Date Created:
    * Last Modified:
    *
    * Specifications, Algorithms, and Assumptions:
    *
    *
    * @param returnUrl:
    * @return ActionResult
    */
 public ActionResult ForgotPassword(EmailVer model)
 {
     return View(model);
 }