Exemplo n.º 1
0
        public IActionResult GetAllForUser()
        {
            StringValues headerValues;

            if (Request.Headers.TryGetValue("Authorization", out headerValues))
            {
                string   token_str = headerValues.First();
                string[] token_arr = token_str.Split(" ");
                var      handler   = new JwtSecurityTokenHandler();
                var      token     = handler.ReadJwtToken(token_arr[1]);

                var user = token.Payload["unique_name"];

                int userId = int.Parse(user.ToString());

                return(Ok(_reservationRepository.GetAllForUser(userId)));
            }

            return(BadRequest());
        }