question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jwt() method does not update the token currentUser()

See original GitHub issue

When 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:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
carlganzcommented, Apr 13, 2020

In addition to fixing this functionality, it would be great if the refresh token process was better documented.

4reactions
carlganzcommented, Oct 20, 2020

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 that auth.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 and this.netlifyIdentity are different instances of the GoTrue object and that is why the call to jwt in authisn’t updating the state in this.netlifyIdentity. I think creating some documented examples of setCookies in combination with Vuex and Redux state management libraries is best solution here.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found