Exemple #1
0
        private static void ChangeEntityRightsAccordingToRlsRights(UserApplicationRights rights)
        {
            if (rights.EntityRights == null || rights.RowLevelRights == null)
            {
                return;
            }

            foreach (var rowLevelRight in rights.RowLevelRights)
            {
                var rlsRight = rowLevelRight.Value;
                if (rlsRight.PermissionType == RowLevelModelPermissionType.No)
                {
                    if (rights.EntityRights.TryGetValue(rlsRight.Name, out var entRight))
                    {
                        entRight.EntityAccessLevel = EntityAccessLevel.No;
                    }
                }
            }
        }
Exemple #2
0
        public static UserApplicationRights GetUserRights(this ISecurityDbContext context, Guid profileId, Guid?userId = null)
        {
            var rights = new UserApplicationRights
            {
                EntityRights   = new Dictionary <string, EntityRightData>(),
                RowLevelRights = new Dictionary <string, RowLevelRightData>()
            };

            if (profileId == Guid.Empty)
            {
                return(rights);
            }

            rights.EntityRights   = GetEntityRightsModel(context, profileId);
            rights.RowLevelRights = GetRowLevelRightsModel(context, profileId, userId);

            ChangeEntityRightsAccordingToRlsRights(rights);

            return(rights);
        }