Numtel-MySQL/React/Admin Only Publications


#1

First would certainly like to thank @numtel for the excellent work on the reactive MySQL package.

I am trying to limit data published to the clients from the server side based on information stored in the MySQL database and as a newbie, I seem to be stuck at the starting line and am afraid of my attempts as far as security is concerned.

The app is designed to do time tracking and I only want admin users to be able to look at the timers/timeslips of other users. Right now my publish code is as follows (backticks are missing due to the forum’s functionality):

Meteor.publish(‘Tickets’, function () {
return liveDb.select(
SELECT tickets.*, users.Name as username, clients.name as clientname FROM tickets left join users on tickets.userid = users.userid left join clients on tickets.clientId = clients.clientid where Status < 4 and users.userId > 0 ORDER BY clients.name ASC, tickets.TicketID DESC,
[{ table: ‘tickets’ }]);
});

How would I go about passing in a Meteor.userId() into the publication, or am I way off track as to how to accomplish this feature?


#2

And I figured out that I needed to use this.userId inside of the publication.