Check if user is logged in inside the server plugin.
-
Hello,
I am a newbie to plugin
and am trying to make a plugin where I will need to check if the user is logged in first prior to any action.I was able to make it work by using a POST type request in client and req.user.uid in server-side function.
Can this work with GET type as well? Somehow req.user is not retrieved in server side library.js function.
Basically I am looking for a way to ensure that any request (regardless of GET/POST) is processed only for users who are logged in. -
Can this work with GET type as well? Somehow req.user is not retrieved in server side library.js function.
This should be possible, ex.
https://github.com/psychobunny/nodebb-plugin-twilio/blob/master/library.js#L8-L9
and
https://github.com/psychobunny/nodebb-plugin-twilio/blob/master/library.js#L29
if (req.user && req.user.uid) { // logged in }
can you link the code perhaps, and git revision if possible
-
@psychobunny Thanks a lot for the info. I will take a look.