Interested in grabbing the user on every request so that I can have funtionality even on pages that don't have any stormpath functionality middleware.
Any issues with this? If user is logged in it returns the user in the request object, if the user is not logged in, it returns undefined. which is exactly what I want. Any 'gotchas' I'm missing? It 'seems' to work great.
app.get('*', stormpath.getUser, function(req, res, next) {
next()
});
That's fine, although your code won't cover all routes & http methods. It's probably easier to do this:
app.use(stormpath.getUser)Since in express, all route handlers are "middleware", you can pass
stormpath.getUserdirectly into the handler without the function callingnext().Also, matching all
GETrequests by using * will miss anyPOST,DELETE,PUT, etc requests.app.allwill match all routes and all HTTP methods.