jwt() method does not update the token currentUser()
See original GitHub issueWhen invoking jwt(true)
, the value in currentUser()
is not updated until a logout then login again. As a user, it would be convenient if the jwt()
method would update the value automatically.
Example:
const user = auth.currentUser();
const jwt = user.jwt(true);
jwt.then(() => {
console.log("User token refreshed.");
console.log(this.netlifyIdentity.currentUser());
});
This code snippet does not result in the new token being console.log
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to update JWT Identity in flask? - Stack Overflow
Show your token generation method, you are using the current JWT or you are decoding the token and retrieve the userId to generate...
Read more >Migrate to Google Identity Services | Authorization
When an access token expires, the gapi.auth2 module automatically obtains a new, valid access token for your web app. For improved user security,...
Read more >A currentUser service for Ember with JWT - Matt Layman
As a user of Ember Simple Auth and Ember Simple Auth Token, I needed to show an authenticated user for College Conductor. By...
Read more >Authenticate a User - Web SDK — Realm - MongoDB
To log in, create an anonymous credential and pass it to App.logIn() : ... The Realm Web SDK includes methods to handle the...
Read more >Node Auth Tutorial (JWT) #17 - Checking the Current User
Your browser can't play this video. Learn more. Switch camera ... Node Auth Tutorial ( JWT ) #17 - Checking the Current User....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In addition to fixing this functionality, it would be great if the refresh token process was better documented.
https://github.com/carlganz/gotruejs-in-vue
After experimenting with this some more I am almost certain this is not a bug, but a common issue people create for themselves that can probably be avoided with some improved documentation.
For example, in the example here, which doesn’t use the remember me functionality, the user info is saved as cookie manually to prevent logging out on refresh. I think a lot of people, including myself, did this even with
setCookies:true
not understanding thatauth.currentUser()
would resolve under the hood. As a result I think people are inadvertently instantiating more than one GoTrue object.In the initial example, it seems pretty clear that
auth
andthis.netlifyIdentity
are different instances of the GoTrue object and that is why the call tojwt
inauth
isn’t updating the state inthis.netlifyIdentity
. I think creating some documented examples of setCookies in combination with Vuex and Redux state management libraries is best solution here.