private bool IsValidRole(SecurityPermission permission, ISecurityQuery query) { if (query.CreatorRole.HasValue && query.Page.HasValue) { var rule = permission.Rules.First(x => x.Page == query.Page); return(rule.IsEditable && (query.Member.CurrentRole == query.CreatorRole.Value || rule.EditRoleList.Contains(query.Member.CurrentRole))); } return(permission.Rules.Any(x => x.ViewRoleList.Contains(query.Member.CurrentRole))); }
private bool IsAllowedPermission(SecurityPermission permission, ISecurityQuery query) { return(IsValidMember(query.Member) && IsValidWeek(query.DayAssignDate) && IsValidDayAssignStatus(query.DayAssignStatus) && IsValidUserRoleList(permission, query) && IsValidUserPlatform(permission, query) && IsValidRole(permission, query) && IsValidTab(permission, query) && IsValidForGroupedTask(permission, query)); }
private bool HasAccess(ISecurityQuery query, SecurityPermission permission) { if (permission == null) { return(false); } var result = IsAllowedPermission(permission, query); return(result); }
private bool IsValidForGroupedTask(SecurityPermission permission, ISecurityQuery query) { var rule = permission.Rules.FirstOrDefault(x => x.Page == query.Page); if (rule == null || !rule.IsDisabledForGroupingTask) { return(true); } return(!query.IsGroupedTask); }
private bool IsValidTab(SecurityPermission permission, ISecurityQuery query) { if (!query.Page.HasValue) { return(true); } var rule = permission.Rules.First(x => x.Page == query.Page); return(rule.ViewRoleList.Contains(query.Member.CurrentRole)); }
private bool IsValidUserPlatform(SecurityPermission permission, ISecurityQuery query) { if (permission.Rules.All(x => x.AllowedPlatformList.Count == 0) || !query.CurrentPlatformType.HasValue) { return(true); } bool result = permission.Rules.Any(x => x.AllowedPlatformList.Contains(query.CurrentPlatformType.Value)); return(result); }
private bool IsValidUserRoleList(SecurityPermission permission, ISecurityQuery query) { if (!permission.Rules.Any(x => x.IsUserShouldHaveAllRoles)) { return(true); } Rule rule = permission.Rules.First(x => x.IsUserShouldHaveAllRoles); bool result = rule.UserRoleList.All(s => query.Member.Roles.Contains(s)); return(result); }
public Dictionary <string, bool> HasAccessByGroupName(ISecurityQuery query) { var permissionList = Get(query.GroupName).ToList(); return(permissionList.ToDictionary(permission => permission.Key, permission => HasAccess(query, permission))); }