Search code examples
passport.jsnestjspassport-jwt

how to refresh JWT Token after username update in NestJS?


I've been using Passport JWT for Auth and the payload for signing is username and seller. Now the issue is that every time i update username and tries to fetch userdetails it gives 401. So i'm looking for a way to handle this gracefully using passport jwt in nestjs


Solution

  • How about using the user id and the seller id as payload? These values won't change and therefore the token stays valid even when the username changes