Created
February 27, 2014 20:29
-
-
Save CaptainYarb/9258881 to your computer and use it in GitHub Desktop.
The real thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assume express and all that goodness (I actually am using Kraken) | |
// my middleware class | |
var userModel = function(userID){ | |
return { | |
uid: userID, | |
logout: function(){ | |
this.uid=false; | |
// how can I access req? | |
req.session.destroy(function(){ | |
// TODO: handle callback | |
}); | |
} | |
}; | |
}; | |
// extend req with my class | |
module.exports = function(){ | |
return function(req,res,next){ | |
req.user = new userModel(uid); | |
next(); | |
} | |
} | |
// so essentially when I want to logout I simply use: | |
req.user.logout(); | |
// how can user.logout access req? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment