You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In V2 we used to (and probably incorrectly) depended on the client to be able to call the admin -> hidden function for a collection. Something like this:
Where that function would then do a check on the current path (albeit not the most smart but we're still in the early stages) to hide what media a given user could see:
/** * Check if the user has the role to view media, otherwise if they * are in a part of the app where they shouldn't see media, hide it based on the * expected pathname part. */exportconsthideMediaOutsidePathAndOnAdminIfNotRole=(expectedPathnamePart: string,roleToCheck: BasicRole)=>(args: {user: User})=>{constpathname=window.location.pathnameconstpathParts=pathname.split('/')if(pathParts[1]==='admin'&&pathParts.length===2){// on the home page, check if the user is a viewerreturn!roleToCheck.passes({req: args}asany)}// Otherwise, we want to make sure they shouldn't see media// parts for a different part of the appreturn!window.location.pathname.includes(expectedPathnamePart)}
We were trying to prevent users working on their pages seeing media for other applications as we have a multi tenant setup. In V3, we can no longer check the current route since the config isn't passed to the frontend and the hidden function call doesn't receive the current request. If there's a better way to do this, I'd love some thoughts.
Just to make sure I'm clarifying the problem:
User of Application A has roles to modify Application A and Media for A. When they go to use a rich text field and inject a media item, the popup appears and shows all the options:
But I really only want them to see the "Slope Media"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
In V2 we used to (and probably incorrectly) depended on the client to be able to call the
admin
->hidden
function for a collection. Something like this:Where that function would then do a check on the current path (albeit not the most smart but we're still in the early stages) to hide what media a given user could see:
We were trying to prevent users working on their pages seeing media for other applications as we have a multi tenant setup. In V3, we can no longer check the current route since the config isn't passed to the frontend and the hidden function call doesn't receive the current request. If there's a better way to do this, I'd love some thoughts.
Just to make sure I'm clarifying the problem:
User of Application A has roles to modify Application A and Media for A. When they go to use a rich text field and inject a media item, the popup appears and shows all the options:
But I really only want them to see the "Slope Media"
Beta Was this translation helpful? Give feedback.
All reactions