fixed bug that does not show usernames of others in /checkout
This commit is contained in:
parent
ff6ee2cf36
commit
91be0dd559
@ -3,7 +3,7 @@
|
|||||||
<p class="pure-u-3-5">Chromebook #{{number}}</p>
|
<p class="pure-u-3-5">Chromebook #{{number}}</p>
|
||||||
{{#if status }}
|
{{#if status }}
|
||||||
<div class="timestamp pure-u-2-5">
|
<div class="timestamp pure-u-2-5">
|
||||||
<p class="user"> <b>{{username}}</b></p>
|
<p class="user"> <b>{{user}}</b></p>
|
||||||
<p class="time">{{time_ago}}</p>
|
<p class="time">{{time_ago}}</p>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@ -18,18 +18,16 @@ Template.chromebook.helpers({
|
|||||||
} else {
|
} else {
|
||||||
return moment(this.last_checkout).fromNow();
|
return moment(this.last_checkout).fromNow();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
username: function() {
|
|
||||||
return Meteor.users.findOne({_id: this.userid}).profile.name;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.chromebook.events({
|
Template.chromebook.events({
|
||||||
'click .available': function() {
|
'click .available': function() {
|
||||||
if (Chromebooks.findOne({userid: Meteor.userId()}) === undefined) {
|
if (Chromebooks.findOne({userid: Meteor.userId()}) === undefined) {
|
||||||
Chromebooks.update(this._id, {$set: {status: 1}});
|
Chromebooks.update(this._id, {$set: {status: 1}});
|
||||||
Chromebooks.update(this._id, {$set: {last_checkout: new Date()}});
|
Chromebooks.update(this._id, {$set: {last_checkout: new Date()}});
|
||||||
Chromebooks.update(this._id, {$set: {userid: Meteor.userId()}});
|
Chromebooks.update(this._id, {$set: {userid: Meteor.userId()}});
|
||||||
|
Chromebooks.update(this._id, {$set: {user: Meteor.user().profile.name}});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'click .checkedout': function() {
|
'click .checkedout': function() {
|
||||||
|
|||||||
@ -1,24 +1,30 @@
|
|||||||
Meteor.publish('chromebook', function() {
|
Meteor.publish('chromebook', function() {
|
||||||
//return Chromebooks.find({}, {fields: {number: 1, status: 1, userid: 1, last_checkout: 1}});
|
// return Chromebooks.find({}, {fields: {number: 1, status: 1, userid: 1, last_checkout: 1}});
|
||||||
/*
|
|
||||||
if (Meteor.user().roles === ['admin']) {
|
// var user = Meteor.user();
|
||||||
|
// console.log("user:", user);
|
||||||
|
// var field;
|
||||||
|
|
||||||
|
// if (user && user.roles[0] == 'admin') {
|
||||||
|
// field = {number: 1, status: 1, userid: 1, last_checkout: 1, serial: 1};
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// field = {number: 1, status: 1, userid: 1, last_checkout: 1};
|
||||||
|
// }
|
||||||
|
// console.log("field:", field);
|
||||||
|
// return Chromebooks.find({}, {fields: field});
|
||||||
|
|
||||||
|
if (Roles.userIsInRole(this.userId, ['admin'])) {
|
||||||
|
|
||||||
return Chromebooks.find();
|
return Chromebooks.find();
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Chromebooks.find({}, {fields: {number: 1, status: 1, userid: 1, last_checkout: 1}});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var user = Meteor.user();
|
} else {
|
||||||
var field;
|
|
||||||
|
// user not authorized. do not publish secrets
|
||||||
|
this.stop();
|
||||||
|
return;
|
||||||
|
|
||||||
if (user && user.roles[0] === 'admin') {
|
|
||||||
field = {number: 1, status: 1, userid: 1, last_checkout: 1, serial: 1};
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
field = {number: 1, status: 1, userid: 1, last_checkout: 1};
|
|
||||||
}
|
|
||||||
return Chromebooks.find({}, {fields: field});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.publish('user', function() {
|
Meteor.publish('user', function() {
|
||||||
@ -40,15 +46,15 @@ for (var i = 0; i < adminusers.length; i++) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Accounts.validateNewUser(function (user) {
|
// Accounts.validateNewUser(function (user) {
|
||||||
var loggedInUser = Meteor.user();
|
// var loggedInUser = Meteor.user();
|
||||||
|
|
||||||
if (Roles.userIsInRole(loggedInUser, ['admin'])) {
|
// if (Roles.userIsInRole(loggedInUser, ['admin'])) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
throw new Meteor.Error(403, "Not authorized to create new users");
|
// throw new Meteor.Error(403, "Not authorized to create new users");
|
||||||
});
|
// });
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
deleteUser: function (targetUserId, group) {
|
deleteUser: function (targetUserId, group) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user