Skip to content

Commit c64362d

Browse files
committed
Update deperecation note for all() method and replaced outdated references with the new everyone() method.
1 parent c82842f commit c64362d

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if (user.authorized('system resource', 'view')) {
2929
</li>
3030
<li>This was originally released as a library for <a href="https://butlerlogic.com" target="_blank">Butler Logic</a> clients. Fortunately, it has become a more generic tool, available for a general audience. As such, we've moved the package from <code>@butlerlogic/iam</code> to <code>@author.io/iam</code>. The Author npm organization is more suitable for long term support.</li>
3131
</ol>
32+
<p>This release also introduced 195 unit tests.</p>
3233
</td>
3334
</tr>
3435
</table>
@@ -307,10 +308,10 @@ If a user was assigned to both the `basic user` _and_ `superuser` roles, the use
307308
308309
### Applying rights to everyone
309310

310-
There is a private/hidden role produced by IAM, called `everyone`. This role is always assigned to all users. It is used to assign permissions which are applicable to every user of the system. A special `all()` method simplifies the process of assigning rights to everyone.
311+
There is a private/hidden role produced by IAM, called `everyone`. This role is always assigned to all users. It is used to assign permissions which are applicable to every user of the system. A special `everyone()` method simplifies the process of assigning rights to everyone.
311312

312313
```javascript
313-
IAM.all({
314+
IAM.everyone({
314315
'resource': 'right',
315316
'admin portal': 'deny:*',
316317
'user portal': 'view', // A single string is valid
@@ -487,7 +488,7 @@ IAM.createResource({
487488
})
488489

489490
// Deny admin portal rights for everyone.
490-
IAM.all({
491+
IAM.everyone({
491492
'admin portal': 'deny:*'
492493
})
493494

examples/ARCHIVE-@butlerlogic-iam/api/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const app = express()
1010
IAM.createResource('blog', ['create', 'read', 'update', 'delete', 'list'])
1111

1212
// Identify rights associated with all users of the system.
13-
IAM.all({
13+
IAM.everyone({
1414
blog: ['read', 'list']
1515
})
1616

examples/ARCHIVE-@butlerlogic-iam/basic/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ IAM.createResource({
99

1010
// Set defaults. Allow users to view the home
1111
// and blog tabs, but deny access to the administrator.
12-
IAM.all({
12+
IAM.everyone({
1313
home: '*',
1414
blog: ['view', 'deny:edit']
1515
})

examples/ARCHIVE-@butlerlogic-iam/ui/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ IAM.createRole('superadmin', {
7878
})
7979

8080
// Grant resource rights to everyone.
81-
IAM.all({
81+
IAM.everyone({
8282
'admin portal': 'deny:*',
8383
settings: '*',
8484
profile: ['view', 'manage']

examples/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Examples
22

3-
We're working on new examples.
3+
See the [codepen examples](https://codepen.io/coreybutler/pen/mdEyQxX).
4+
5+
The source is documented, and the unit tests provide other examples.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@author.io/iam",
3-
"version": "1.0.0-alpha.2",
3+
"version": "1.0.0-alpha.3",
44
"description": "A Identification and Authorization Management library.",
55
"main": "src/index.js",
66
"module": "index.js",

src/lib/manager.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default class Manager extends Base {
118118
reset () {
119119
this.#items = new Map()
120120
this.#named = new Map()
121-
globalThis[REGISTRY_ID].all()
121+
globalThis[REGISTRY_ID].everyone()
122122
super.reset()
123123
}
124124
}

src/lib/registry.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ class Registry extends Base {
420420
}
421421

422422
all () {
423-
console.warn('IAM.all() is deprecated. Use IAM.everyone() instead.')
423+
const location = (new Error()).stack.split('\n').slice(1, 2).join('').trim()
424+
console.warn('IAM.all() is deprecated. Use IAM.everyone() instead ' + location)
424425
this.everyone(...arguments)
425426
}
426427

@@ -559,7 +560,7 @@ class Registry extends Base {
559560
for (const role of cfg.roles) {
560561
if (role.name && role.rights) {
561562
if (role.name === 'everyone') {
562-
this.all(role.rights)
563+
this.everyone(role.rights)
563564
} else {
564565
const r = this.createRole(role.name, role.rights)
565566
if (role.description) {

0 commit comments

Comments
 (0)