예제 #1
0
        public static UserSession GetSession()
        {
            var requestObj = HttpContext.Current.Request.Headers.GetValues("sessionId");
            var sessionId  = HttpContext.Current.Request.Headers != null?HttpContext.Current.Request.Headers.Get("sessionid") : null;

            if (sessionId == null)
            {
                sessionId = HttpContext.Current.Request.Headers.Get("sessionId");
            }
            try
            {
                var userSession = SecurityServices.LookupSession(sessionId);
                if (!IsSessionExist(sessionId))
                {
                    throw  new Exceptions.InvalidSessionFailure();
                }

                var UserId  = Convert.ToString(HttpContext.Current.Request.Headers["UserId"]);
                var action  = Convert.ToString(HttpContext.Current.Request.Headers["ActionName"]);
                var AgentId = Convert.ToString(HttpContext.Current.Request.Headers["AgentId"]);
                //if (!string.IsNullOrEmpty(pluginName))
                //{
                //    List<PermissionInfo> permissions = GetActionPermissions(UserId, pluginName, action);
                //    if (permissions.Count() > 0)
                //        return userSession;
                //    else
                //        throw GenerateServiceError("You are not authorized to do this Action.", HttpStatusCode.Forbidden, new LogMessage(EnumLogLevel.Warn, new Exception()));
                //}
                //else
                return(userSession);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }