I successfully use Node.js + Express + Everyauth ( https://github.com/abelmartin/Express-And-Everyauth/blob/master/app.js ) to log in to Facebook, Twitter, etc. from my application.
The problem I'm trying to circle my head with is that Everyauth seems to "set up and forget." I created one everyauth object and configured it as an expression middleware, and then forgot about it. For example, if I want to create a mobile login on Facebook, I do:
var app = express.createServer(); everyauth.facebook .appId('AAAA') .appSecret('BBBB') .entryPath('/login/facebook') .callbackPath('/callback/facebook') .mobile(true);
Here's the problem: Both mobile and non-mobile clients will connect to my server, and I do not know what it is connecting to until a connection is established. Worse, I need to support multiple Facebook application identifiers (and, again, I don't know which one I want to use until the client connects and I partially analyze the input). Since everyauth is a singleton that was configured once, I donβt see how to make these configuration changes based on the request made.
It seems that I need to create some middleware that acts before everyauth middleware to configure everyauth object, so that everyauth subsequently uses the correct appId / appSecret / mobile parameters. I have no idea how to do this ...
Suggestions?
Here is the best idea that I have so far, although it seems awful: Create an everyauth object for each possible configuration, using a different entryPath for each ...
source share