Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f90627c
make package.json NPM compatible
jgoux Apr 22, 2015
910f466
Fix ui-router name
jgoux Apr 22, 2015
aaca114
Corrected spelling
shoaibmerchant Jun 15, 2015
0b44374
Update package.json
RafaelVidaurre Jul 2, 2015
f80fa16
Merge pull request #73 from chaaya/development
Jul 7, 2015
fda09eb
Bump version
RafaelVidaurre Jul 7, 2015
f86a016
Merge branch 'development'
RafaelVidaurre Jul 7, 2015
a176817
Update README.md
Jul 8, 2015
0916187
Merge pull request #70 from shoaibmerchant/patch-1
Aug 28, 2015
b3d4424
Merge pull request #62 from jgoux/jgoux-patch-issue-60
Sep 30, 2015
241f447
Bump version
RafaelVidaurre Sep 30, 2015
1580787
Bump in bower
RafaelVidaurre Sep 30, 2015
6e0707f
Merge pull request #84 from Narzerus/development
Sep 30, 2015
62064f9
Update to 1.1.0 because NPM
RafaelVidaurre Sep 30, 2015
ad1dec7
Fix package json errors
RafaelVidaurre Sep 30, 2015
2b62ef2
Update README.md
Oct 13, 2015
f14e002
Merge branch 'master' of https://github.com/Narzerus/angular-permission
paulorbpacheco Oct 30, 2015
3c3b3e0
Urgent fix: Defining roles is not working for instantiated service
masterspambot Nov 7, 2015
994bcb2
Merge pull request #90 from masterspambot/patch-2
Nov 9, 2015
386e202
Bump version
RafaelVidaurre Nov 9, 2015
751e7a5
Urgent fix: Defining roles is not working for instantiated service
masterspambot Nov 7, 2015
fe0c3e4
Bump version
RafaelVidaurre Nov 9, 2015
6949c20
Merge branch 'development' of github.com:Narzerus/angular-permission …
RafaelVidaurre Nov 9, 2015
fc31e3c
Merge pull request #91 from Narzerus/development
Nov 9, 2015
02ce046
Merge branch 'master' of https://github.com/Narzerus/angular-permission
paulorbpacheco Nov 10, 2015
4f67ca1
README updated.
paulorbpacheco Nov 10, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ Another thing you can do is set a redirect url to which unauthorized sessions wi
});
```

Setting directives permissions/roles
-------------------------------

This is how simple is to set which permission can or not read a html element.

```html
<div class="container">
<div class="jumbotron text-center">
<h1>Home</h1>
<ul class="list-group">
<li class="list-group-item" rp-only="admin">ADMIN</li>
<li class="list-group-item" rp-only="moderator">MODERATOR</li>
<li class="list-group-item" rp-except="anonymous">EXCEPT_ANONYMOUS</li>
</ul>
</div>
</div>
```

There are three directives available for use:

* rp-only
* rp-except
* rp-state

Defining roles
--------------------------
Expand Down Expand Up @@ -140,6 +163,17 @@ For that you can use promises
});
});
```

You can also define many roles which share the same validator. This is useful when you have some central service which handles the validation.

To define many roles which share one validator callback, use `defineManyRoles(<array>, <validator function>)`

```javascript
Permission.defineManyRoles(arrayOfRoleNames, function (stateParams, roleName) {
return User.hasRole(roleName);
});
```

As you can see, Permission is useful wether you want a role-based access control or a permission-based one, as
it allows you to define this behaviour however you want to.

Expand All @@ -155,7 +189,7 @@ Events
Caveats
=======
Because of a bug in ui-router, when using `$urlStateProvider.otherwise` we get an **infinite digest** loop error.
A workaround was found by [@shaoibmerchant](https://github.com/shoaibmerchant) and it goes like this:
A workaround was found by [@shoaibmerchant](https://github.com/shoaibmerchant) and it goes like this:

```javascript
// Normal usage (creates INFDG error)
Expand All @@ -171,7 +205,7 @@ $urlRouterProvider.otherwise( function($injector) {
TODOS:
-----
Help fill this list with your feature requests
- More powerful redirection to allow passing state parameters and other useful stuff ui-router provides. Ideas anyone?
- [Waiting for release on `ui-router`'s end] More powerful redirection to allow passing state parameters and other useful stuff ui-router provides. Ideas anyone?
- Inheritance (example: 'admin' inherits from 'user')
- Role validation caching?

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-permission",
"version": "0.3.0",
"version": "1.1.1",
"authors": [
"Rafael Vidaurre <[email protected]>"
],
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-permission.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* angular-permission
* Route permission and access control as simple as it can get
* @version v0.3.0 - 2015-07-10
* @version v1.1.1 - 2015-11-09
* @link http://www.rafaelvidaurre.com
* @author Rafael Vidaurre <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
Expand Down Expand Up @@ -315,7 +315,7 @@
scope where it is defined and therefore can interact with other modules
**/
validateRoleDefinitionParams(roleName, validationFunction);
roleValidationConfig[roleName] = validationFunction;
Permission.roleValidations[roleName] = validationFunction;

return Permission;
},
Expand Down
52 changes: 50 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
{
"dependencies": {},
"name": "angular-permission",
"version": "1.1.1",
"description": "Route permission and access control as simple as it can get",
"author": {
"name": "Rafael Vidaurre",
"email": "[email protected]"
},
"main": "dist/angular-permission.js",
"repository": {
"type": "git",
"url": "https://github.com/Narzerus/angular-permission.git"
},
"keywords": [
"angular",
"permissions",
"roles",
"route"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Narzerus/angular-permission/issues"
},
"homepage": "http://www.rafaelvidaurre.com",
"peerDependencies": {
"angular-ui-router": "^0.2.11"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
Expand All @@ -19,5 +44,28 @@
},
"scripts": {
"test": "grunt karma:unit"
}
},
"name": "angular-permission",
"description": "![alt tag](https://travis-ci.org/Narzerus/angular-permission.svg?branch=master)",
"main": "dist/angular-permission.js",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Narzerus/angular-permission.git"
},
"keywords": [
"permission",
"angular",
"routes",
"ui-router",
"access"
],
"author": "Rafael Vidaurre",
"license": "MIT",
"bugs": {
"url": "https://github.com/Narzerus/angular-permission/issues"
},
"homepage": "https://github.com/Narzerus/angular-permission#readme"
}
2 changes: 1 addition & 1 deletion src/permission.svc.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
scope where it is defined and therefore can interact with other modules
**/
validateRoleDefinitionParams(roleName, validationFunction);
roleValidationConfig[roleName] = validationFunction;
Permission.roleValidations[roleName] = validationFunction;

return Permission;
},
Expand Down