Source: bemap-services-v2/acl/bemap-acl-service.js

/**
 * BeNomad BeMap JavaScript API - AclService (v1.5)
 *
 * Promise-based wrapper around the BeMap ACL endpoints. The primary entry
 * point is `getCurrentUserDetails()` which calls
 * `GET service/acl/1.0/user/details` and returns a typed
 * `bemap.AclDetailsResponse` carrying the user's username, granted roles,
 * accessible geoservers, and accessible charging-station providers.
 *
 * **Why you want this in a customer app.** The geoserver list is filtered
 * server-side by the user's ACL — so this is the right way to populate a
 * "Geoserver" dropdown that only shows entries the user can actually use,
 * with the default one pre-selected. Calling against a different geoserver
 * key would return a 403 from the data services.
 *
 * Typical use:
 *
 *     var acl = new bemap.AclService(ctx);
 *     acl.getCurrentUserDetails().then(function(details) {
 *         details.getGeoservers().forEach(function(gs) {
 *             addOption(gs.getKey(), gs.getValue(), gs.isDefault());
 *         });
 *     });
 *
 * @since 1.5.0
 * @public
 * @constructor
 * @extends {bemap.ServiceV2}
 * @param {bemap.Context} context BeMap-JS-API Context. Mandatory.
 * @param {Object} [options]
 */
bemap.AclService = function(context, options) {
    bemap.ServiceV2.call(this, context, options);
};
bemap.inherits(bemap.AclService, bemap.ServiceV2);

/**
 * Fetch the current authenticated user's ACL details.
 *
 * @public
 * @param {Object} [options]
 * @param {AbortSignal} [options.signal]
 * @return {Promise<bemap.AclDetailsResponse>}
 */
bemap.AclService.prototype.getCurrentUserDetails = function(options) {
    return this._get('service/acl/1.0/user/details', options || {})
        .then(function(json) {
            return bemap.AclDetailsResponse.fromJson(json);
        });
};