diff --git a/client/app.js b/client/app.js index 6deaf26e8..899768915 100644 --- a/client/app.js +++ b/client/app.js @@ -1,7 +1,4 @@ -Meteor.subscribe('users', function(){ - // once we've subscribed, set a session variable to check if the current user is an admin - Session.set('currentUserIsAdmin', (Meteor.user() && !Meteor.user().loading) ? isAdmin(Meteor.user()) : false ); -}); +Meteor.subscribe('users'); Posts = new Meteor.Collection('posts'); Meteor.subscribe('posts'); @@ -15,10 +12,10 @@ Meteor.subscribe('comments', function() { Settings = new Meteor.Collection('settings'); Meteor.subscribe('settings', function(){ - if(proxinoKey=getSetting('proxinoKey')){ + if((proxinoKey=getSetting('proxinoKey'))){ Proxino.key = proxinoKey; Proxino.track_errors(); - } + } }); Session.set('state', 'list'); diff --git a/client/templates/comment_form.html b/client/templates/comment_form.html index 929cdbbf0..4ec82dd96 100644 --- a/client/templates/comment_form.html +++ b/client/templates/comment_form.html @@ -1,16 +1,14 @@ \ No newline at end of file + {{/constant}} +
+ +
+ + + diff --git a/client/templates/comment_form.js b/client/templates/comment_form.js index 99a52ede4..ea2e6030d 100644 --- a/client/templates/comment_form.js +++ b/client/templates/comment_form.js @@ -1,9 +1,3 @@ -Template.comment_form.helpers({ - show_comment_form: function(){ - return Meteor.user() !== null; - } -}); - Template.comment_form.rendered = function(){ if(Meteor.user() && !this.editor){ this.editor = new EpicEditor(EpicEditorOptions).load(); @@ -35,4 +29,3 @@ Template.comment_form.events = { } }; - diff --git a/client/templates/comment_item.html b/client/templates/comment_item.html index 7f40946dc..8a54950ca 100644 --- a/client/templates/comment_item.html +++ b/client/templates/comment_item.html @@ -1,6 +1,6 @@ diff --git a/client/templates/settings.html b/client/templates/settings.html index e98910954..519e1efb8 100644 --- a/client/templates/settings.html +++ b/client/templates/settings.html @@ -6,7 +6,7 @@ {{#if no_settings}}

No settings yet.

{{/if}} - {{#if currentUserIsAdmin}} + {{#if currentUser.isAdmin}}
diff --git a/client/templates/settings.js b/client/templates/settings.js index 346595f53..47b70babb 100644 --- a/client/templates/settings.js +++ b/client/templates/settings.js @@ -41,9 +41,6 @@ Template.settings.events = { } }; -Template.settings.currentUserIsAdmin = function(){ - return currentUserIsAdmin(); -} Template.settings.no_settings = function(){ if(Settings.find().fetch()[0]){ return false; diff --git a/client/templates/user_edit.js b/client/templates/user_edit.js index f744c73cb..c93d902af 100644 --- a/client/templates/user_edit.js +++ b/client/templates/user_edit.js @@ -36,7 +36,7 @@ Template.user_edit.events = { Template.user_edit.user = function(){ var current_user=Meteor.user(); - if(window.selected_user_id && !current_user.loading && isAdmin(current_user)){ + if(window.selected_user_id && !current_user.loading && current_user.isAdmin){ return Meteor.users.findOne(window.selected_user_id); }else{ return current_user; diff --git a/client/templates/user_item.html b/client/templates/user_item.html index adacd91d5..a831331ef 100644 --- a/client/templates/user_item.html +++ b/client/templates/user_item.html @@ -14,6 +14,6 @@ {{comments_count}} {{karma}} - {{#if is_admin}}{{/if}} + {{#if currentUser.isAdmin}}{{/if}} \ No newline at end of file diff --git a/client/templates/user_item.js b/client/templates/user_item.js index 7f68ea913..bb890297f 100644 --- a/client/templates/user_item.js +++ b/client/templates/user_item.js @@ -34,7 +34,3 @@ Template.user_item.comments_count = function(){ // Posts.find({'user_id':this._id}).forEach(function(post){console.log(post.headline);}); return Comments.find({'user_id':this._id}).count(); } - -Template.user_item.is_admin = function(){ - return isAdmin(this); -} \ No newline at end of file diff --git a/lib/helpers.js b/lib/helpers.js index cb95c92a8..0387f6aa4 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -8,10 +8,6 @@ var breakTag = '
'; return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); } -currentUserIsAdmin = function(){ - return Session.get('currentUserIsAdmin'); -} - getSetting = function(setting){ var settings=Settings.find().fetch()[0]; if(settings){ diff --git a/lib/permissions.js b/lib/permissions.js deleted file mode 100644 index 9512b4572..000000000 --- a/lib/permissions.js +++ /dev/null @@ -1,4 +0,0 @@ -isAdmin=function(userOrId){ - var user= typeof userOrId === 'string' ? Meteor.users.findOne(userOrId) : userOrId; - return user && user.isAdmin; -} \ No newline at end of file diff --git a/server/publish.js b/server/publish.js index 233868b0b..788b5b6b1 100644 --- a/server/publish.js +++ b/server/publish.js @@ -1,4 +1,8 @@ // Users +isAdmin=function(userId){ + var user = Meteor.users.findOne(userId); + return user && user.isAdmin; +} Meteor.publish('users', function() { if (this.userId() && isAdmin(this.userId())) { @@ -92,7 +96,7 @@ Meteor.startup(function(){ if(isAdmin(userId) || (docs[0].user_id && docs[0].user_id==userId)){ return true; } - return false; + return false; } }); }); diff --git a/smart.lock b/smart.lock index 2bf1a1a10..f41a51f12 100644 --- a/smart.lock +++ b/smart.lock @@ -2,7 +2,7 @@ "meteor": { "git": "https://github.com/meteor/meteor.git", "branch": "auth", - "commit": "687407a4d3be776635d3b59242e8304d9e29abdb" + "commit": "d2616308361203215c122f962ae9a5c763b5ca09" }, "dependencies": { "basePackages": {