Documentation 3.0 Beta
Checking User Permissions on the Client
A permission defines an allowed action by a user. For example, one permission could allow a read action, while another allows a delete action.
When the user makes a request to an endpoint controlled by an app scope running on the Akula Server, the app scope first determines if the user has the required permission to access the endpoint. If the user has the required permission, then the request is allowed. If the user does not have the required permission, then the request fails. For the failed request, though, the client app must incur the overhead of making the server request, and then waiting for the server response, only to have the request fail.
Alternatively, you can make the permission check on the client before making the request to the Akula Server. If the user does not have the required permissions, then you can handle it immediately on the client app without incurring any server overhead.
In addition, your client app might support offline functionality or local operations. Because the Akula Server returns the user's permissions on log in, you can use these permissions in your client app to control user access to offline or local resources.
This document contains the following sections:
Accessing user permissions on the client
Before making a request to the Akula Server, you can use this information to determine if the user has the necessary permission to access an Akula Server endpoint. For example, a user needs the "Sales.write" permission to write to a particular endpoint. An Android client app can use the following code to determine if the user has the necessary permission before making the request:
Refreshing user permissions on the client
If user permissions are updated on the Akula Server at runtime, the client can use the
refreshAllSync() methods (Android),
syncRefreshAll: methods on the AKPermissions instance (iOS) to download the updates. These methods download all of the permissions, not just the ones that have been modified.
On Android, call
refreshAll() asynchronously and
refreshAllSync() synchronously. On iOS, use
refreshAll: to make an asynchronous request and
syncRefreshAll: to make a synchronous request. For more information, see Synchronous and Asynchronous Requests.