This tutorial explains how you can use the Permissioning API to find out from the server, which products the logged-in user is allowed to use, in order to display the appropriate information to the user.
When developing a component which deals with several products, you might want to find out which ones the user has permission to view or trade upon, before displaying them within the component.
For example: Imagine that you want to know which currency pairs to display in a selection list. The following code snippet can be used to customise the list’s contents:
var permissionService = caplin.core.ServiceRegistry.getService("caplin.permission-service"); var pCurrencyList = ["/FX/GBPUSD","/FX/EURUSD","/FX/AUDUSD","/FX/GBPEUR",…]; var sNamespace = null; var sAction = "VIEW"; var pPermissionedCurrencyList = permissionService.getPermissionedProducts(pCurrencyList, sNamespace, sAction); //code to populate select box with pPermissionedCurrencyList
The “getPermissionedProducts” function, returns a subset of the array of products passed to it, containing only those which the user is allowed (in this particular example) to view. The complementary function “getUnpermissionedProducts” is also available.