Adapt user interface depending on REST API authorizations.
1 person uses it
Submitted by: 229633?v=3 nfroidure


AngularJS tools to customize users interfaces based on their rights on the REST API.

Quick start

Consider the following template:

IT will display add/edit/delete buttons depending on the user rights comparing to the methods and pathes set for the given predefined rights.

Predefined rights are set in your application configuration like this: ```js angular.module('myApp') .config(['sfReaccessServiceProvider', 'profileService', function(sfReaccessServiceProvider) {

}]); ```

User rights are set by using the sfReaccessService.setRights() method, they look like this: js sfReaccessService.setRights([{ path: "/users/:_id/?.*", methods: [ "OPTIONS", "HEAD", "GET", "POST", "PUT", "PATCH", "DELETE" ] },{ path: "/organisations/:organisation_id/?.*", methods: [ "OPTIONS", "HEAD", "GET", "POST", "PUT", "PATCH", "DELETE" ] }]);

Path values are templated regular expressions. To set objects where to search for template expressions values, use sfReaccessService.setValues(): js sfReaccessService.setValues([{ _id: 1, organisation_id: 1 }]);


You can enable sfReaccess debug mode globally:

Or locally as an argument to the angular filter: html <button ng-show="'USER_ADD' | sfReaccess: undefined : true" ng-click="addUser()">Add a user</button>


To contribute to this project, first run the following to setup the development environment: sh npm install bower install

Then, run the tests and debug with Karma: sh npm run dev

Note for Express users

If you use Express for your backend, you may be interested by the express-reaccess middleware.

comments powered by Disqus
This page was last updated about 4 years ago.