Hi,
I have the following
before('pass', function() {
if (!session.passport.user) {
next();
} else {
if(session.LoggedInUser){
this.blah = "BLAH!";
next();
}else{
User.find(session.passport.user, function(err, user) {
if (user && user.approved) {
session.LoggedInUser = user;
req.user = user;
this.loggedInUser = user;
}
next();
});
}
}}.bind(this));
before('auth', function() {
console.log(this.blah);
// other stuff happens here, but nothing that undefines this.blah;
}.bind(this));
auth comes after pass, since my session.LoggedInUser is set when I do my console.log it says BLAH!
then in another controller I
load('application');
and
action(function index() {
layout("application");
console.log(this.blah);
});
when I do the console.log on this.blah is says undefined.
Why?
If I have a bind on my User.find inside of pass then I can bind what I want and pass it along, as long as I call that User.find.
I had expected I could just move the bind out to the outer function but that doesn't work.
What do I have to do inside of the part of pass that says
if(session.LoggedInUser){
this.blah = "BLAH!";
next();
}
in order to bind blah?
Thanks,
Bryan Rasmussen