Commit 2ae1791
authored
fix: tokens (#113)
### 1. Local Storage Not Updated
Access tokens and refresh tokens are only saved to local storage on
login, subsequent token refreshes do not update local storage.
<br><b>Example:</b> User refreshes to a new token and exits Overleaf,
the next time he re-opens PaperDebugger, it uses the old refresh token.
<br><b>Proposed solution:</b> Update authStore whenever tokens are set.
<br>
### 2. Race Conditions When Refreshing
PaperDebugger often calls multiple endpoints at the same time, which
results in a race condition if the token needs to be refreshed.
<br><b>Example:</b> `v2/chats/models` and `v2/chats/conversations` are
called at the same time, and the access token needs refreshing, the
refresh endpoint is called twice. In some occasions, the frontend uses
the 2nd refresh token received which differs from the one stored in the
backend. This can be easily reproduced by setting the JWT expiration in
the backend to a very short time.
<br><b>Proposed solution:</b> Use a promise for `refresh()`.
<br>
<br>
Unsure if this fixes the exact problem in #1101 parent de12255 commit 2ae1791
1 file changed
Lines changed: 25 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
101 | 117 | | |
102 | 118 | | |
103 | 119 | | |
| |||
0 commit comments