public AuthorizeAttribute(double minAppVersion, bool allowAnonymous = false, OsNames os = OsNames.Everything, params string[] allowedOsVersions)
        {
            AllowAnonymous    = allowAnonymous;
            MinimumAppVersion = minAppVersion;

            AllowedOs         = os.ToString();
            AllowedOsVersions = allowedOsVersions.Where(x => !string.IsNullOrEmpty(x)).ToArray();

            Status = new AuthorizeStatus
            {
                Message = StatusEnum.Forbidden.GetDisplayName(),
                Success = false
            };
        }
示例#2
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (SmsCache.UserContext == null || SmsCache.UserContext.UserID == 0 || SmsCache.UserContext.CurrentBranchId == 0)
            {
                Status = AuthorizeStatus.NotLogin;
                return(false);
            }

            if (!SmsCache.UserAccesses.AuthorizeSession())
            {
                HttpContext.Current.Session.Abandon();

                Status = AuthorizeStatus.NotLogin;
                return(false);
            }

            var authorized = SmsCache.UserContext.IsSystemAdmin ||
                             SmsCache.UserContext.AllowPageIDs.Contains(pageID);

            Status = !authorized ? AuthorizeStatus.DontHaveAccessRight : AuthorizeStatus.HasAccessRight;

            return(authorized);
        }
示例#3
0
 private AuthorizeResult(T?val, AuthorizeStatus status)
 {
     Status = status;
     Value  = val;
 }
示例#4
0
 private AuthorizeResult(AuthorizeStatus status)
 {
     Status = status;
 }