示例#1
0
        private void HandleAthorizaion(HttpActionContext actionContext)
        {
            var Db_Content = new Db_Content();
            var UserId     = actionContext.Request.Headers.GetValues("UID").FirstOrDefault();
            int parsedId;

            if (int.TryParse(UserId, out parsedId))
            {
                var currentUser = Db_Content.GetUser(parsedId);
                if (currentUser != null)
                {
                    if (!currentUser.IsAllowed)
                    {
                        actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized - This Is User dosent have the needed premission");
                    }
                }
                else
                {
                    actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "Unauthorized - This Is User does not exist in the system");
                }
            }
            else
            {
                actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, "UnAthorize - Missing Token");
            }
        }
示例#2
0
 public ScansController()
 {
     _scanService = new Scan();
     _Db_Content  = new Db_Content();
 }