I have a sailing application that I work with, and I use pass.js for the auth user. I have a login, along with the policies that protect my pages, all systems go. On one of my pages, the user enters information, so I need to get the current registered user ID. I struggled with this, but eventually came up with a route
In the controller
$scope.$on('sailsSocket:connect', function(ev, data) { sailsSocket.get( '/get_user', {}, function(response) { $scope.team_id = response.user; sailsSocket.get( '/status_update?sort=createdAt%20ASC&team_id='+$scope.team_id, {}, function(response) { $scope.updates = response; $log.debug('sailsSocket::/status_update', response); }); }); });
and route callback
get_user: function(req, res) { res.json({user:req.session.passport.user}); },
It seems to work correctly, but I have a few questions.
a) is this the right way to do this? Passing this information to the controller along the route?
b) cause nested socket calls like this good practice?
I am new to this stack and still feel my way through it, so any feedback is greatly appreciated.
user2812463
source share