Skip to content

Commit 77056e8

Browse files
committed
Merge pull request #1 from pdsoftplan/master
Project Updated to latest version. Thanks to @paulorbpacheco.
2 parents 19a3fc5 + 4f67ca1 commit 77056e8

File tree

5 files changed

+90
-8
lines changed

5 files changed

+90
-8
lines changed

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,29 @@ Another thing you can do is set a redirect url to which unauthorized sessions wi
7575
});
7676
```
7777

78+
Setting directives permissions/roles
79+
-------------------------------
80+
81+
This is how simple is to set which permission can or not read a html element.
82+
83+
```html
84+
<div class="container">
85+
<div class="jumbotron text-center">
86+
<h1>Home</h1>
87+
<ul class="list-group">
88+
<li class="list-group-item" rp-only="admin">ADMIN</li>
89+
<li class="list-group-item" rp-only="moderator">MODERATOR</li>
90+
<li class="list-group-item" rp-except="anonymous">EXCEPT_ANONYMOUS</li>
91+
</ul>
92+
</div>
93+
</div>
94+
```
95+
96+
There are three directives available for use:
97+
98+
* rp-only
99+
* rp-except
100+
* rp-state
78101

79102
Defining roles
80103
--------------------------
@@ -140,6 +163,17 @@ For that you can use promises
140163
});
141164
});
142165
```
166+
167+
You can also define many roles which share the same validator. This is useful when you have some central service which handles the validation.
168+
169+
To define many roles which share one validator callback, use `defineManyRoles(<array>, <validator function>)`
170+
171+
```javascript
172+
Permission.defineManyRoles(arrayOfRoleNames, function (stateParams, roleName) {
173+
return User.hasRole(roleName);
174+
});
175+
```
176+
143177
As you can see, Permission is useful wether you want a role-based access control or a permission-based one, as
144178
it allows you to define this behaviour however you want to.
145179

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

160194
```javascript
161195
// Normal usage (creates INFDG error)
@@ -171,7 +205,7 @@ $urlRouterProvider.otherwise( function($injector) {
171205
TODOS:
172206
-----
173207
Help fill this list with your feature requests
174-
- More powerful redirection to allow passing state parameters and other useful stuff ui-router provides. Ideas anyone?
208+
- [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?
175209
- Inheritance (example: 'admin' inherits from 'user')
176210
- Role validation caching?
177211

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-permission",
3-
"version": "0.3.0",
3+
"version": "1.1.1",
44
"authors": [
55
"Rafael Vidaurre <[email protected]>"
66
],

dist/angular-permission.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* angular-permission
33
* Route permission and access control as simple as it can get
4-
* @version v0.3.0 - 2015-07-10
4+
* @version v1.1.1 - 2015-11-09
55
* @link http://www.rafaelvidaurre.com
66
* @author Rafael Vidaurre <[email protected]>
77
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -315,7 +315,7 @@
315315
scope where it is defined and therefore can interact with other modules
316316
**/
317317
validateRoleDefinitionParams(roleName, validationFunction);
318-
roleValidationConfig[roleName] = validationFunction;
318+
Permission.roleValidations[roleName] = validationFunction;
319319

320320
return Permission;
321321
},

package.json

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
{
2-
"dependencies": {},
2+
"name": "angular-permission",
3+
"version": "1.1.1",
4+
"description": "Route permission and access control as simple as it can get",
5+
"author": {
6+
"name": "Rafael Vidaurre",
7+
"email": "[email protected]"
8+
},
9+
"main": "dist/angular-permission.js",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/Narzerus/angular-permission.git"
13+
},
14+
"keywords": [
15+
"angular",
16+
"permissions",
17+
"roles",
18+
"route"
19+
],
20+
"license": "MIT",
21+
"bugs": {
22+
"url": "https://github.com/Narzerus/angular-permission/issues"
23+
},
24+
"homepage": "http://www.rafaelvidaurre.com",
25+
"peerDependencies": {
26+
"angular-ui-router": "^0.2.11"
27+
},
328
"devDependencies": {
429
"grunt": "^0.4.5",
530
"grunt-contrib-clean": "^0.5.0",
@@ -19,5 +44,28 @@
1944
},
2045
"scripts": {
2146
"test": "grunt karma:unit"
22-
}
47+
},
48+
"name": "angular-permission",
49+
"description": "![alt tag](https://travis-ci.org/Narzerus/angular-permission.svg?branch=master)",
50+
"main": "dist/angular-permission.js",
51+
"directories": {
52+
"test": "test"
53+
},
54+
"repository": {
55+
"type": "git",
56+
"url": "git+https://github.com/Narzerus/angular-permission.git"
57+
},
58+
"keywords": [
59+
"permission",
60+
"angular",
61+
"routes",
62+
"ui-router",
63+
"access"
64+
],
65+
"author": "Rafael Vidaurre",
66+
"license": "MIT",
67+
"bugs": {
68+
"url": "https://github.com/Narzerus/angular-permission/issues"
69+
},
70+
"homepage": "https://github.com/Narzerus/angular-permission#readme"
2371
}

src/permission.svc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
scope where it is defined and therefore can interact with other modules
108108
**/
109109
validateRoleDefinitionParams(roleName, validationFunction);
110-
roleValidationConfig[roleName] = validationFunction;
110+
Permission.roleValidations[roleName] = validationFunction;
111111

112112
return Permission;
113113
},

0 commit comments

Comments
 (0)