I don't like this answer, but I figured I'd post my quick fix for the time being:
I'm setting a credentials
field in the user's session, so what I'm doing is just checking to see if credentials
exists in the /getMe session. If it doesn't, delete the session. Here's the updated code:
app/controllers/mytests_controller.js
action('getMe', function(data) {
// Added this part
var session = data.req.session;
if (session && !session.credentials) {
session.destroy();
}
return send({success: true, data: 'got you!'});
});
action(function index(data) {
// Added this part
var session = data.req.session;
if (session) {
session.credentials = "blah blah blah";
}
var http = require('http');
var options = {
path: '/getMe',
host: 'localhost',
port: 3000
};
// return send({success: true});
http.get(options, function(res) {
var data = '';
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
data = JSON.parse(data);
if (data) {
// make call for proper config file based on cookie.role
return send({success: true, data: data});
}
else {
return send({success: false, data: 'data is undefined'});
}
});
});
});
Like I said, it's not ideal, so I would love to hear other answers... maybe if there's a way to send a session through an http.get or even telling the http.get to not create a session would be awesome.