We have a view parameter roles
which which we’d like to fill in with a comma separated list of roles like Authenticated/Roles/Role1, Authenticated/Roles/Role2
. The roles and number of roles vary. We can check this parameter with a script transform on a binding to parameter like the code below, enabling a component if the user has any of the roles listed (this version doesn’t use the Authenticated/Roles
prefix on each role):
return any(role.strip() in value for role in self.view.params.roles.split(','))
Is there a way we can do this as an expression binding like the one following (which does not work if there’s more than one role listed in the roles
parameter)?
isAuthorized(False, {view.params.roles})
&& len({view.params.roles}) > 0 // Prevent authorization with empty roles parameter.
What we’re aiming for is a way to fill in a varying number of arguments as surrounded by stars below in the expression from a single string parameter:
isAuthorized(False, **role1, role2, roleN**)
I feel like I must be missing something simple…