radu
radu

Reputation: 606

Multiple login paths for everyauth

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'.

Upvotes: 0

Views: 78

Answers (2)

sachin.ph
sachin.ph

Reputation: 1078

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.

Upvotes: 0

radu
radu

Reputation: 606

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'
  ]))

Upvotes: 0

Related Questions