I'm using a passport-freshbooks strategy, which is like pretty much like any other strategy, except I think it's not authored properly (if I'm not missing anything). I've found that you need to pass a variable to its middleware in its definition phase, which you can only get from the user through a route handler.
passport.use(new FreshbooksStrategy({
// This is the USER's subdomain, who's supposed to login
subdomain: SUBDOMAIN,
...
To set the subdomain
above, you need to first get it from the user
app.get('/login', function(req,res){
res.send('<form>Enter your freshbooks account URL or subdomain(..submit)</form>')
});
app.post('/login', function(req,res){
var subdomain = req.body.subdomain.split('.')[0].split('/').pop();
});
So how could I set this subdomain
in the passport strategy's middleware definition above?
It might need to alter the strategy itself but I'm not sure how to proceed, any ideas?