Replies: 2 comments 2 replies
-
Not sure what this does: if (!credentials.email) {
return {
refreshing: true
};
} The
|
Beta Was this translation helpful? Give feedback.
-
Ok, first things first. In my case the data from the Also, I've managed to change my flow for refreshing. Approach from the first comment is wrong even if possible. Right now I'm triggering the That allows me to run validation for my internal token and refresh if needed. Thanks for the response! MAINTAINER COMMENT: Changed a word for clarity for others in the future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
Hi and thanks for the great tool for authorization for next.js. It's a crucial part of every app and thanks to you I'm able to integrate simply with a lot of providers! 😄
Opening for the issue:
In my solution, I'm integrating with my custom backend where I'm also getting a pair of tokens. This part is done for now. I managed to refresh the tokens inside the
authorize
method after calling the signIn from next-auth/react.Also, I saw a discussion in the #1350 issue and that was very helpful for me but I come with a different approach for it.
My refreshing logic looks like this:
I'm using the CredentialsProvider provider to manage it and it's working cool. I just wanted to clarify one possible case which maybe you could add in the future or help to figure it out for me.
The real question is here:
Is there any chance to return or to obtain the current token object in the
jwt
callback? Even if the return inauthorize
is not the same as during the login process. Right now it returns empty fields in the object (See comments in the demo)That will allow me to delete this whole parsing and encoding part from authorizing and simply allows me to run my refreshAsseccToken method if needed in the
jwt
callback.Also if you have any feedback due to the current refreshing flow - I'm all ears 😄
Right now the variable token seems to be cleaned when calling this callback. Dunno why exactly...
My jwt callback right now:
As I understand (and it's simplified) after returning obj in the authorize method jwt callback is called and I can access the payload of the token. Maybe one of the params should still contain old values of the last known JWT payload?
How to reproduce ☕️
Demo link with the main idea here.
I don't think it clearly shows what I mean b/c we can't make real requests. But check out the
console.logs
and comments in thejwt
callback.Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions