Beispiel #1
0
 static void AddActions(string userOrRoleId, string parentAction, List <AccessNodeSaveModel> childActions)
 {
     if (childActions == null)
     {
         return;
     }
     foreach (var ac in childActions)
     {
         var action = ac.Action;
         if (!string.IsNullOrEmpty(parentAction))
         {
             action = parentAction + "." + action;
         }
         if (ac.Access == NodeAccessType.HasAccess)
         {
             AuthorizationManager.RevokeAccess(userOrRoleId, action);
             AuthorizationManager.AddAction(userOrRoleId, action);
         }
         else if (ac.Access == NodeAccessType.NoAccess)
         {
             AuthorizationManager.RevokeAccess(userOrRoleId, action);
         }
         else if (ac.SubActions != null)
         {
             AuthorizationManager.RevokeAccess(userOrRoleId, action, false);
             AddActions(userOrRoleId, action, ac.SubActions);
         }
     }
 }