Esempio n. 1
0
        protected override bool IsAuthorized(System.Web.Http.Controllers.HttpActionContext actionContext)
        {
            var headers = actionContext.Request.Headers.Authorization;

            if (headers != null)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(SessionHelper.SessionId))
                    {
                        return(false);
                    }
                    CacheManagement _cache      = new CacheManagement();
                    var             sessionData = _cache.GetSessionData(headers.Scheme);
                    if (sessionData.ExpirationDate > DateTime.Now)
                    {
                        return(true);
                    }
                }
                catch
                {
                    //return false;
                }
                finally
                {
                }
            }
            return(false);
        }
Esempio n. 2
0
 protected override void Initialize(HttpControllerContext controllerContext)
 {
     try
     {
         base.Initialize(controllerContext);
         this._caching = new CacheManagement();
         string token = controllerContext.Request.Headers.Authorization.ToString();
         this.UserId         = this._caching.GetSessionData(token).UserId;
         this.OrganizationId = this._caching.GetSessionData(token).OrganizationId;
         this.RoleId         = this._caching.GetSessionData(token).RoleId;
     }
     catch (Exception ex)
     {
         ErrorLog.LogError(ex);
     }
 }