Комментарии:
Hey Dennis! Excellent tutorial, as always!
Can you also show us how to do registration and also how a logged in authenticated user can do post requests to create/update notes?
Cheers, bro!
Thank youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
ОтветитьGreat stuff!
ОтветитьThis is legit the best video I found on this topic. Also, we use the same vscode theme.. lol
Ответитьthe api should really be in the dependency array of the useeffect, but that would then cause an infinite re-render loop
Ответитьthis would create a race condition when multiple requests starts in parallel. Example: Request A has expired token -> refresh token POST request starts to renew it -> While the refresh request is still going Request B enters the chat -> has expired token -> starts a new Refresh Token Request. This creates a race condition. A lock/queue mechanism MUST be implemented to call this a real solution. I'm sorry but this tutorial is actually misleading.
ОтветитьAmazing video, learned a lot...
Ответитьi think the reason that people check in in the response rather than pre-request is that it is a more general approach that works on a wider range of back-end applications where you are not 100% sure of how the back-end is set up and how it validates the tokens. For example if there is something other than time that makes the token invalid, you renew the token as a standard procedure upon request fail regardless of why that is. However, if you have full control over the back-end and know all possible outcomes (aka you know that you need to check the exp time) I think intercepting before the request makes more much more sense.
ОтветитьGreat video, I would point out though that refreshing the auth token in the useEffect is inefficient. IMO it would be better to store the expiration time of the token, and then whenever you need to access the API you check the expiration time, and update the access token if necessary.
ОтветитьForgive me if I am wrong, but shouldnot we check the expiry of the refresh token too before requesting a new access and refresh token? Just in case the user hasn't logged in for more than 90 days, so we simply logout the user.
ОтветитьAmazingg!!! Thanks for this, i have been trying to learn how to manage the auth flow and now i know how. Thank u soo muchh. Saludos desde Mexico
ОтветитьNice explanation man. Your side tangents really helped us understand the entire context.
Ответитьi agree
i dont know alot of people are trying to refresh token at frontend stack.
its done with a one middleware .
Anything on social login please?
ОтветитьHello everyone, first of all I'm sorry for my bad English I'm tall and I've worked with the translator xd
Well, I think that in react in the updateToken function in the first conditional after creating data (yes, the one with status === 200) the resfresh token should be added in data, at least if I don't add it, the resfresh doesn't work since it needs to. Greetings and good night to all coders ;)
Great tutorial. Thank you for the quality content!
ОтветитьThat's my boy, I started following u since last year. You're awesome
ОтветитьI'm having an issue when I first login and my Authtoken doesn't appear. because of this I would have to refresh the page then it's there along with other backEnd data. How do I fix this? I've google this issue and couldn't find any solution.
ОтветитьThak you for this awesome video.
Ответить