Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Add method for updating JWT #260

Closed
Mangatt opened this issue Aug 2, 2016 · 2 comments
Closed

Add method for updating JWT #260

Mangatt opened this issue Aug 2, 2016 · 2 comments
Milestone

Comments

@Mangatt
Copy link

Mangatt commented Aug 2, 2016

Hi,
it would be great if server could issue new token with new data - new expiration or session-like data. Now i couldn't do either, token have to expire by itself and then can be issued and session-like data can be saved in connection object, but are lost after connection and reconnection.

@ekryski
Copy link
Member

ekryski commented Aug 4, 2016

@Mangatt You can always make a request using a valid token and it will return a new one, albeit with the same data and expiration, unless you setup a before hook on the auth/token service to alter the JWT payload.

We have some fixes coming in the 0.8 branch that will make it easier to issue tokens with different options and different payloads.

@ekryski ekryski modified the milestone: 0.8 Aug 9, 2016
@ekryski
Copy link
Member

ekryski commented Nov 21, 2016

With the new 1.0.0 version of auth you can create a new JWT at any time by calling:

const options = app.get('auth');
app.passport.createJWT(payload, options)

or providing whatever custom JWT options you would like:

const options = {
  secret: 'your secret',
  jwt: {
   // your custom options. See https://github.com/auth0/node-jsonwebtoken
  }
};
app.passport.createJWT(payload, options)

So it is entirely up to you when you would like to do it.

@ekryski ekryski closed this as completed Nov 21, 2016
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants