Ejemplo n.º 1
0
        public IActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                Account account = AccountDb.IsLoginValid(model);
                if (account != null)
                {
                    SessionHelper.LogUserIn(_httpAccessor, account.AccountId, account.Username);
                    TempData["Message"] = "Logged in successfully";
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "You didn't enter the correct information");
                }
            }

            return(View(model));
        }