Exemplo n.º 1
0
        public ActionResult ForgottenPassword()
        {
            var viewModel = new AuthForgottenPasswordViewModel() {
                Username = string.Empty
            };

            return View("ForgottenPassword", viewModel);
        }
Exemplo n.º 2
0
        public ActionResult ForgottenPassword(AuthForgottenPasswordViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return View("ForgottenPassword", viewModel);
            }

            using (var context = new RowanHouseDb())
            {
                var account = context.Users.FirstOrDefault(e => e.Username.ToLower().Equals(viewModel.Username.ToLower()));
                account.Password = PasswordGenerator.Generate();
                context.Entry(account).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
            }

            return RedirectToAction("LogIn");
        }