// public ActionResult ForgotPassword(Models.ForgotPasswordViewModel model)
        public ActionResult ForgotPassword(Models.ResetPasswordViewModel model)
        {
            string emailAddress = model.Email;

            var user = db.FundRaisers.FirstOrDefault(s => s.Email.Equals(emailAddress));

            string callbackUrl = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/FundRaisers/verify1?ID="
                                 + user.verificationToken;
            MailMessage mail = new MailMessage();

            mail.To.Add(model.Email);
            mail.From    = new MailAddress("*****@*****.**");
            mail.Subject = "Reset Password";



            mail.Body       = "Hello there!" + "<br/>" + "Please click on the link below to reset your password... " + "<br/>" + callbackUrl + "<br/>" + "<br/>" + "<br/>" + "<br/>" + "<br/>" + "If this is not you, please send us an email at [email protected] " + "<br/>" + "<br/>" + "<br/>" + "Sincerely," + "<br/>" + "Team Origin";
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();

            smtp.Host = "smtp.gmail.com";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials           = new System.Net.NetworkCredential
                                             ("*****@*****.**", "fall2015cmps285");// Enter senders User name and password
            smtp.EnableSsl = true;
            Console.WriteLine("Sending email .... ");
            smtp.Send(mail);



            return(View("PasswordRecovery"));
        }
Esempio n. 2
0
        public ActionResult ResetPassword(Models.ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            _bllAccount.ResetPassword(model.Id, model.Password1);

            AlertSuccess(@"Your password was successfully reset.");

            return(Redirect(@"/"));
        }
        public ActionResult ResetPassword(Models.ResetPasswordViewModel model)
        {
            var user = db.FundRaisers.FirstOrDefault(m => m.Email.Equals(model.Email));

            if (user.Password != "")
            {
                string newPassword = Crypto.HashPassword(model.Password);
                user.Password        = newPassword;
                user.ConfirmPassword = newPassword;

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 4
0
 public ActionResult ResetPassword(Models.ResetPasswordViewModel model)
 {
     //if (!ModelState.IsValid)
     //{
     //    return View(model);
     //}
     //var user =  UserManager.FindByEmail(model.Email);
     //if (user == null)
     //{
     //    // 请不要显示该用户不存在
     //    return RedirectToAction("ResetPasswordConfirmation", "Account");
     //}
     //var result =  UserManager.ResetPassword(user.Id, model.Code, model.Password);
     //if (result.Succeeded)
     //{
     //    return RedirectToAction("ResetPasswordConfirmation", "Account");
     //}
     //AddErrors(result);
     return(View());
 }
Esempio n. 5
0
        public async Task <ActionResult> ResetPassword(Models.ResetPasswordViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user = await UserManager.FindByNameAsync(model.Email);

            if (user == null)
            {
                // Don't reveal that the user does not exist
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);

            if (result.Succeeded)
            {
                return(RedirectToAction("ResetPasswordConfirmation", "Account"));
            }
            AddErrors(result);
            return(View());
        }