Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] remove underscore #268

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v1.2.16

* Support new MongoDB version.

## v1.2.15

* Wrap localStorage in try/catch to avoid crash when disabled. #182


## v1.2.14

* Compatibility with Meteor 1.2. #133
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Thanks to:
<a id="roles-authorization" name="roles-authorization"></a>
### Authorization

This package lets you attach permissions to a user which you can then check against later when deciding whether to grant access to Meteor methods or publish data. The core concept is very simple, essentially you are attaching strings to a user object and then checking for the existance of those strings later. In some sense, it is very similar to tags on blog posts. This package provides helper methods to make the process of adding, removing, and verifying those permissions easier.
This package lets you attach permissions to a user which you can then check against later when deciding whether to grant access to Meteor methods or publish data. The core concept is very simple, essentially you are attaching strings to a user object and then checking for the existence of those strings later. In some sense, it is very similar to tags on blog posts. This package provides helper methods to make the process of adding, removing, and verifying those permissions easier.

All versions of Meteor from 0.5 to current are supported (excluding Meteor 0.9.1). UI-less apps are supported as well.

Expand All @@ -72,7 +72,7 @@ You can have traditional roles like, "admin" or "webmaster", or you can assign m

Sometimes it's useful to let a user have independent sets of permissions. The `roles` package calls these independent sets, "groups" for lack of a better term. You can think of them as "partitions" if that is more clear. Users can have one set of permissions in group A and another set of permissions in group B. Let's go through an example of this using soccer/football teams as groups.

```
```js
Roles.addUsersToRoles(joesUserId, ['manage-team','schedule-game'], 'manchester-united.com')
Roles.addUsersToRoles(joesUserId, ['player','goalie'], 'real-madrid.com')

Expand All @@ -86,7 +86,7 @@ NOTE: If you use groups for _ANY_ of your users, you should use groups for _ALL_

Now, let's take a look at how to use the Global Group. Say we want to give Joe permission to do something across all of our groups. That's what the Global Group is for:

```
```js
Roles.addUsersToRoles(joesUserId, 'super-admin', Roles.GLOBAL_GROUP)

if (Roles.userIsInRole(joesUserId, ['manage-team', 'super-admin'], 'real-madrid.com')) {
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/Roles.html
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ <h4>Parameters:</h4>


<div class="param-description">
<p>Name(s) of roles to add users to</p>
<p>Name(s) of roles to remove users from</p>

</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@
},
{
"name": "roles",
"description": "Name(s) of roles to add users to",
"description": "Name(s) of roles to remove users from",
"type": "Array|String"
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/files/roles_roles_common.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ <h1 class="file-heading">File: roles/roles_common.js</h1>
*
* @method removeUsersFromRoles
* @param {Array|String} users User id(s) or object(s) with an _id field
* @param {Array|String} roles Name(s) of roles to add users to
* @param {Array|String} roles Name(s) of roles to remove users from
* @param {String} [group] Optional. Group name. If supplied, only that
* group will have roles removed.
*/
Expand Down
13 changes: 9 additions & 4 deletions roles/client/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@

Roles.debug = false

if (localStorage) {
var temp = localStorage.getItem("Roles.debug")
try {
if (localStorage) {
var temp = localStorage.getItem("Roles.debug")

if ('undefined' !== typeof temp) {
Roles.debug = !!temp
if ('undefined' !== typeof temp) {
Roles.debug = !!temp
}
}
} catch (ex) {
// ignore: accessing localStorage when its disabled throws
// https://github.com/meteor/meteor/issues/5759
}
4 changes: 2 additions & 2 deletions roles/client/uiHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Roles._uiHelpers = {
if (!Match.test(role, String)) return false

if (comma !== -1) {
roles = _.reduce(role.split(','), function (memo, r) {
roles = role.split(',').reduce(function (memo, r) {
if (!r || !r.trim()) {
return memo
}
Expand Down Expand Up @@ -83,7 +83,7 @@ if (Roles.debug && console.log) {
if ('undefined' !== typeof Package.blaze &&
'undefined' !== typeof Package.blaze.Blaze &&
'function' === typeof Package.blaze.Blaze.registerHelper) {
_.each(Roles._uiHelpers, function (func, name) {
Roles._uiHelpers.forEach(function (func, name) {
if (Roles.debug && console.log) {
console.log("[roles] registering Blaze helper '" + name + "'")
}
Expand Down
7 changes: 4 additions & 3 deletions roles/package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
summary: "Authorization package for Meteor",
version: "1.2.14",
version: "1.2.16",
git: "https://github.com/alanning/meteor-roles.git",
name: "alanning:roles"
});
Expand All @@ -10,8 +10,7 @@ Package.onUse(function (api) {

api.versionsFrom("[email protected]");

api.use(['underscore',
'accounts-base',
api.use(['accounts-base',
'tracker',
'mongo',
'check'], both);
Expand All @@ -30,6 +29,8 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
var both = ['client', 'server'];

api.versionsFrom("[email protected]");

// `accounts-password` is included so `Meteor.users` exists

api.use(['alanning:roles',
Expand Down
Loading