Beispiel #1
0
 public string CreateClaimCode(PermissionItem item, PermissionAction action)
 {
     return($"{item.ToString()}.{action.ToString()}");
 }
Beispiel #2
0
        public bool Check(long userId, PermissionItem item, PermissionAction[] actions)
        {
            var actionsList = actions.Select(x => x.ToString().ToLower()).ToList();

            using (var connection = _connector.GetConnection())
            {
                var userIsAdmin = _permissionReader.UserIsAdmin(connection, userId);
                if (userIsAdmin)
                {
                    return(true);
                }
                var permissions = _permissionReader.GetUserPermissions(connection, userId, item.ToString().ToLower());
                var result      = permissions.Where(x => actionsList.Contains(x.Action.ToLower())).Any();
                return(result);
            }
        }