Ejemplo n.º 1
0
        public ActionResult ProcessLoginInput(string username, string password, int? rememberMe)
        {
            try
            {
                Account account = _accountService.GetAccount(username, password);

                bool persistCookie = rememberMe > 0;
                HttpCookie httpCookie = _webAuthenticationService.CreateAuthCookie(username, account.Role.ToString(),
                                                                                   persistCookie);
                Response.Cookies.Add(httpCookie);

                if (account.MustChangePassword)
                {
                    var changePasswordViewModel =
                        new ChangePasswordViewModel(new List<string> {"You must change your password"});
                    return View("ChangePassword", changePasswordViewModel);
                }

                return RedirectToAction("Dashboard", "Home");
            }
            catch (ObjectNotFoundException)
            {
                var viewModel = new LoginViewModel();
                viewModel.AddMessage("Invalid Username/Password combination.");
                return View("Login", viewModel);
            }
            catch (Exception exception)
            {
                _logger.LogException(exception);
                return RedirectToAction("Generic", "Error");
            }
        }
Ejemplo n.º 2
0
        public ActionResult Login()
        {
            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Dashboard", "Home");
            }

            var viewModel = new LoginViewModel();
            if (TempData["Message"] != null)
                viewModel.AddMessage(TempData["Message"].ToString());
            return View("Login", viewModel);
        }