简体   繁体   English

Redux和并发令牌刷新请求

[英]Redux and concurrent token refresh requests

We are working on a Redux app and using thunks to encapsulate any async calls and compose multiple actions. 我们正在开发Redux应用程序,并使用thunk封装任何异步调用并编写多个操作。 I am coming up against an interesting problem; 我遇到一个有趣的问题; when the auth token expires and I hit a section of my app that has multiple concurrent calls to the api there is a race to refresh the token which results in a 200 followed my n 401 s as the winner of the race successfully refreshes the token only to leave the runners up to pass the stale token and be denied. 当auth令牌到期并且我点击了应用程序中具有多个并发调用api的部分时,就会进行刷新令牌的竞赛,这导致200跟随我的n 401秒,因为竞赛的获胜者仅成功刷新了令牌离开跑步者以传递过时的令牌并被拒绝。 In our implementation this results in a logout which kinda defeats the purpose of a refresh token... 在我们的实现中,这导致注销,这有点违反了刷新令牌的目的...

Should I write a middle ware and queue any actions that result in failed refresh requests and replay them? 我是否应该编写一个中间件并将任何导致刷新请求失败的操作排入队列,然后重播它们? I am unsure about a clean solution to this but I figure that there must be others having similar issues. 我不确定是否有解决方案,但是我认为必须存在其他类似问题。

有人在这里写了我正在考虑的中间件https://github.com/esbenp/redux-refresh-token

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM