public static bool isAuthorized(Type featureType) { if (Config.Manager.CURRENT_USER == null) { return(false); } string userType = Config.Manager.CURRENT_USER.UserType; var feature = featureType.GetCustomAttributes(typeof(FeatureAttribute), true).FirstOrDefault() as FeatureAttribute; if (feature == null) { return(false); } if (FeaturePropertiesMap == null || FeaturePropertiesMap.Count == 0) { InitFeatureProperties(); } if (AuthorizationMap == null || AuthorizationMap.Count == 0) { AuthorizationMap = DefinitionDao.GetUserAuthorizationMap(); } //Check if (!AuthorizationMap.ContainsKey(userType)) { return(false); } return(AuthorizationMap.GetValue(userType).Contains(feature.Id)); }
private static void InitAuthorizationNameMap() { if (FeaturePropertiesMap == null || FeaturePropertiesMap.Count == 0) { InitFeatureProperties(); } if (AuthorizationMap == null || AuthorizationMap.Count == 0) { AuthorizationMap = DefinitionDao.GetUserAuthorizationMap(); } foreach (var pair in AuthorizationMap) { List <int> ListFeatureId = pair.Value; List <string> ListFeatureName = new List <string>(); foreach (int id in ListFeatureId) { FeatureAttribute attr = ListFeatureAttribute.FirstOrDefault(n => n.Id == id); if (attr == null) { continue; } ListFeatureName.Add((attr.Name + attr.Group).ToKey()); } AuthorizationNameMap[pair.Key] = ListFeatureName; } }
public static Dictionary <string, List <int> > GetAuthorizationMap() { if (AuthorizationMap == null || AuthorizationMap.Count == 0) { AuthorizationMap = DefinitionDao.GetUserAuthorizationMap(); } return(AuthorizationMap); }
public static bool isAuthorized(string userType, int featureId) { if (FeaturePropertiesMap == null || FeaturePropertiesMap.Count == 0) { InitFeatureProperties(); } if (AuthorizationMap == null || AuthorizationMap.Count == 0) { AuthorizationMap = DefinitionDao.GetUserAuthorizationMap(); } //Check if (!AuthorizationMap.ContainsKey(userType)) { return(false); } return(AuthorizationMap.GetValue(userType).Contains(featureId)); }