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

Removed underscore, raised min Meteor version to 1.6.0 #279

Closed
wants to merge 1 commit into from
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ var users = [
{name:"Admin User",email:"[email protected]",roles:['admin']}
];

_.each(users, function (user) {
users.forEach(function (user) {
var id;

id = Accounts.createUser({
Expand All @@ -218,7 +218,7 @@ _.each(users, function (user) {
});

if (user.roles.length > 0) {
_.each(user.roles, function (role) {
user.roles.forEach(function (role) {
Roles.createRole(role, {unlessExists: true});
});
// Need _id of existing user record so this call must come after `Accounts.createUser`.
Expand Down
4 changes: 2 additions & 2 deletions examples/flow-router-advanced/main/client/layouts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Template.mainLayout.helpers({
notVerified: function () {
notVerified: function () {
var user = Meteor.user()

return !emailVerified(user)
}
})

function emailVerified (user) {
return _.some(user.emails, function (email) {
return user.emails.some(function (email) {
return email.verified
})
}
2 changes: 1 addition & 1 deletion examples/flow-router-advanced/main/client/lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ App = {}

"use strict"

_.extend(App, {
Object.assign(App, {

// Separate routing package details from general app code.
navigateTo: function (path) {
Expand Down
8 changes: 4 additions & 4 deletions examples/flow-router-advanced/main/server/startup/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ function createUsers () {
{name:"Admin User",email:"[email protected]",roles:['admin']}
];

_.each(users, function (userData) {
users.forEach(function (userData) {
var id

console.log(userData);

id = Accounts.createUser({
Expand All @@ -41,12 +41,12 @@ function createUsers () {
Meteor.users.update({_id: id},
{$set:{'emails.0.verified': true}});

_.each(userData.roles, function (role) {
userData.roles.forEach(function (role) {
Roles.createRole(role, {unlessExists: true});
});

Roles.addUsersToRoles(id, userData.roles);

});
}
}
4 changes: 2 additions & 2 deletions examples/flow-router-advanced/secrets/server/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Meteor.startup(function () {

function createSecrets () {
var secrets

if (Meteor.secrets.find().fetch().length === 0) {
console.log('Creating secrets: ');

Expand All @@ -23,7 +23,7 @@ function createSecrets () {
{secret:"domain registration pw: apple3"}
]

_.each(secrets, function (secret) {
secrets.forEach(function (secret) {
console.log(secret)

Meteor.secrets.insert(secret);
Expand Down
4 changes: 2 additions & 2 deletions examples/flow-router/client/layouts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Template.mainLayout.helpers({
notVerified: function () {
notVerified: function () {
var user = Meteor.user()

return !emailVerified(user)
}
})

function emailVerified (user) {
return _.some(user.emails, function (email) {
return user.emails.some(function (email) {
return email.verified
})
}
12 changes: 6 additions & 6 deletions examples/flow-router/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Meteor.startup(function () {
////////////////////////////////////////////////////////////////////
// Create Test Secrets
//

if (Meteor.secrets.find().fetch().length === 0) {
Meteor.secrets.insert({secret:"ec2 password: apple2"});
Meteor.secrets.insert({secret:"domain registration pw: apple3"});
Expand All @@ -34,10 +34,10 @@ Meteor.startup(function () {
{name:"Admin User",email:"[email protected]",roles:['admin']}
];

_.each(users, function (userData) {
users.forEach(function (userData) {
var id,
user;

console.log(userData);

id = Accounts.createUser({
Expand All @@ -49,12 +49,12 @@ Meteor.startup(function () {
// email verification
Meteor.users.update({_id: id}, {$set:{'emails.0.verified': true}});

_.each(userData.roles, function (role) {
userData.roles.forEach(function (role) {
Roles.createRole(role, {unlessExists: true});
});

Roles.addUsersToRoles(id, userData.roles);

});
}

Expand Down Expand Up @@ -102,7 +102,7 @@ Meteor.publish("users", function () {
if (Roles.userIsInRole(user, ["admin","manage-users"])) {
console.log('publishing users', this.userId);
return Meteor.users.find({}, {fields: {emails: 1, profile: 1, roles: 1}});
}
}

this.stop();
return;
Expand Down
4 changes: 2 additions & 2 deletions examples/iron-router/client/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Meteor.navigateTo = function (path) {
}

function emailVerified (user) {
return _.some(user.emails, function (email) {
return user.emails.some(function (email) {
return email.verified
})
}

var filters = {

/**
* ensure user is logged in and
* ensure user is logged in and
* email verified
*/
authenticate: function () {
Expand Down
12 changes: 6 additions & 6 deletions examples/iron-router/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Meteor.startup(function () {
////////////////////////////////////////////////////////////////////
// Create Test Secrets
//

if (Meteor.secrets.find().fetch().length === 0) {
Meteor.secrets.insert({secret:"ec2 password: apple2"});
Meteor.secrets.insert({secret:"domain registration pw: apple3"});
Expand All @@ -34,10 +34,10 @@ Meteor.startup(function () {
{name:"Admin User",email:"[email protected]",roles:['admin']}
];

_.each(users, function (userData) {
users.forEach(function (userData) {
var id,
user;

console.log(userData);

id = Accounts.createUser({
Expand All @@ -49,12 +49,12 @@ Meteor.startup(function () {
// email verification
Meteor.users.update({_id: id}, {$set:{'emails.0.verified': true}});

_.each(userData.roles, function (role) {
userData.roles.forEach(function (role) {
Roles.createRole(role, {unlessExists: true});
});

Roles.addUsersToRoles(id, userData.roles);

});
}

Expand Down Expand Up @@ -102,7 +102,7 @@ Meteor.publish("users", function () {
if (Roles.userIsInRole(user, ["admin","manage-users"])) {
console.log('publishing users', this.userId);
return Meteor.users.find({}, {fields: {emails: 1, profile: 1, roles: 1}});
}
}

this.stop();
return;
Expand Down
9 changes: 4 additions & 5 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ Package.describe({
Package.onUse(function (api) {
var both = ['client', 'server'];

api.versionsFrom("METEOR@1.4.1");
api.versionsFrom("METEOR@1.6");

api.use(['underscore',
'accounts-base',
api.use(['accounts-base',
'tracker',
'mongo',
'check'], both);
Expand All @@ -28,15 +27,15 @@ Package.onUse(function (api) {
});

Package.onTest(function (api) {
api.versionsFrom("METEOR@1.4.1");
api.versionsFrom("METEOR@1.6");

var both = ['client', 'server'];

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

api.use(['alanning:roles',
'accounts-password',
'underscore',
'mongo',
'tinytest'], both);

api.addFiles('roles/tests/client.js', 'client');
Expand Down
10 changes: 5 additions & 5 deletions roles/client/uiHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//
// Use a semi-private variable rather than declaring UI
// helpers directly so that we can unit test the helpers.
// XXX For some reason, the UI helpers are not registered
// XXX For some reason, the UI helpers are not registered
// before the tests run.
//
Roles._uiHelpers = {
Expand All @@ -40,7 +40,7 @@ Roles._uiHelpers = {
* @param {String} [scope] Optional, name of scope to check.
* @return {Boolean} `true` if current user is in at least one of the target roles.
* @static
* @for UIHelpers
* @for UIHelpers
*/
isInRole: function (role, scope) {
var user = Meteor.user(),
Expand All @@ -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 || !Roles._trim(r)) {
return memo
}
Expand Down Expand Up @@ -83,10 +83,10 @@ 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) {
Object.entries(Roles._uiHelpers).forEach(([name, func]) => {
if (Roles.debug && console.log) {
console.log("[roles] registering Blaze helper '" + name + "'")
}
Package.blaze.Blaze.registerHelper(name, func)
Package.blaze.Blaze.registerHelper(name, func)
})
}
Loading