예제 #1
0
        public IActionResult Login(AuthenticateModel model)
        {
            try
            {
                string token = _userService.Authenticate(model.Username, model.Password);
                if (token == null)
                {
                    ViewBag.Error = true;
                    return(View("Login"));
                }

                Response.Cookies.Append("JWToken", token);
                HttpContext.Session.SetString("JWToken", token);
                CommonFn.SetToken(token);
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }