Esempio n. 1
0
        public static long?GetInitiatorId(this Controller controller)
        {
            var headers = controller.HttpContext.Request.Headers;

            if (!headers.ContainsKey("Authorization"))
            {
                return(null);
            }

            var token = headers["Authorization"].First();

            return(SessionsService.GetSession(token));
        }
Esempio n. 2
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            base.OnActionExecuting(context);
            var headers = context.HttpContext.Request.Headers;

            if (!headers.ContainsKey("Authorization"))
            {
                context.Result = new HttpStatusCodeResult(401);
                return;
            }

            var token  = headers["Authorization"].First();
            var userId = SessionsService.GetSession(token);

            if (!userId.HasValue)
            {
                context.Result = new HttpStatusCodeResult(401);
                return;
            }
        }