Exemplo n.º 1
0
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, SlackRequirement requirement)
        {
            string token = accessor.HttpContext.Request.Headers["token"].ToString();

            if (UserSlack.GetUserByToken(token) == null)
            {
                AuthorizationFilterContext filtre = context.Resource as AuthorizationFilterContext;
                filtre.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
            }

            return(Task.Run(() => context.Succeed(requirement)));
        }
Exemplo n.º 2
0
 public IActionResult Post([FromBody] Message message, [FromHeader] string token)
 {
     //string token = Request.Headers["token"].ToString();
     message.user = UserSlack.GetUserByToken(token);
     return(new JsonResult(new { Status = message.Add(), message = new { Content = message.Content, user = message.user.UserName, dateAdded = message.DateAdded } }));
 }