Ejemplo n.º 1
0
        public ActionResult Authenticate(UserViewModel loginModel)
        {
            try
            {
                var isUserExist = _historyRepository.Authenticate(loginModel.Username, loginModel.Password);
                Set("Token", AppSettings.TokenKey, 20);

                if (isUserExist)
                {
                    return(RedirectToAction("AdminPosts", "Admin"));
                }

                ViewData["ErrorMessage"] = "Неправильний логін чи пароль.";

                return(View(loginModel));
            }
            catch (Exception)
            {
                return(Json(new { success = false }));
            }
        }