Пример #1
0
        public IActionResult Login(LoginModel loginModel)
        {
            var model = user.FirstOrDefault(p => p.UserName == loginModel.UserName && p.Password == loginModel.Password);

            if (model is null)
            {
                return(View("Index", loginModel));
            }

            var token = _jwtHelper.CreateAuthenticationTicket(model);

            _contextAccessor.HttpContext.Response.Cookies.Append("jwt-token", token);

            return(RedirectToAction("Privacy"));
        }