I created a userHasPermission()
custom function that I'm using all over my app for authorization purposes. Currently, the function looks like this:
bool userHasPermission(
UserPermission requiredPermission,
List<String> authenticatedPermissions,
) {
if (authenticatedPermissions.length < 1) return false;
return authenticatedPermissions.contains(requiredPermission.name);
}
Currently, to use this function, I have to first fetch a user's permissions (from Supabase) and then pass those permissions into the function as authenticatedPermissions
. However, I would rather just have userHasPermission()
fetch the user permissions so that I can eliminate the authenticatedPermissions
argument.
How can I send a Supabase query from inside of userHasPermission()
?