Multiple login paths for everyauth

80 views Asked by At

I have a node.js + express project that's using everyauth. I'm in the process of reworking the routes and I would like to have multiple routes for the login and logout paths so two api versions can coexist at the same time.

Calling postLoginPath multiple times just makes the last call "win".

I need the login code to respond to both "/login" and "/v1/login". I was trying to register the alternate route and do some sort of server-side forward but can't find the '/login' path (which is supplied to postLoginPath) in the registered routes in 'app.routes'.

2

There are 2 answers

0
radu On BEST ANSWER

Ended up using this: https://npmjs.org/package/connect-modrewrite

Here's some sample code for my example:

app.use(modRewrite([
    '/v1/login /login',
    '/v1/logout /logout'
  ]))
0
sachin.ph On

You can use everyauth also.

You can have array of value for the entryPath variable.

 everyauth.facebook
.entryPath(['/url/path1','/url/path2']) 
.callbackPath('/auth/facebook/callback')
.scope('email')                       
.fields('id,name,email,picture')

Also you can get the entryPath value by

 everyauth.facebook.entryPath();

Hope this will be helpful.