コード例 #1
0
        public ActionResult ForgottenPassword()
        {
            var viewModel = new AuthForgottenPasswordViewModel() {
                Username = string.Empty
            };

            return View("ForgottenPassword", viewModel);
        }
コード例 #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");
        }