Heh, I was trying this exact same thing almost two years ago on NodeBB: http://stackoverflow.com/questions/21624503/load-external-scripts-with-requirejs-without-access-to-config
Accessing the user's uid in the plugin's library.js
I can access the uid value in my plugin's controller using this req.uid.
Now I need to access this uid value in the plugin's library.js. How can I access it?
One way is to send the uid in the ajaxify data object (passed to res.render()) which is accessible to the client side js in the ajaxify.data object, and pass the uid from client side to socket.emit. Finally, library.js can access the socket data. But this seems to be a long procedure.
Is there any other easy way to achieve this?
@cool socket.uid works for socket handlers. The socket object is the first argument.
Cool answer.. It worked. Thanks.