Commit 7a31c02
authored
fix: logout-inactivity route gets stuck on loading indicator when inactivity and isLoggedIn are true (#14596)
### What?
Updates logic within the `logout-inactivity` route to handle scenarios
when `inactivity` and `isLoggedIn` are true, which can occur when the
app is open in multiple tabs.
### Why
A client found that the `/logout-inactivity` route can get stuck on the
loading indicator when you are running Payload in multiple tabs.
For example:
1. You have 2 tabs
2. Both tabs logout due to inactivity and redirect to
`/logout-inactivity`
3. I open one tab and login without opening the second tab
4. I open the second tab, the `logout-inactivity` route is still present
and now receives `inactivity: true` and `isLoggedIn: true` because you
logged in using the other tab
5. This combination falls between the gaps in the `/logout-inactivity`
handler and does not get redirected
### How
On the `/logout-inactivity` we have a `useEffect` that checks if
`isLoggedIn: true`, if yes it calls the logout handlers, if false it
redirects to the login screen.
In this above example, it calls the logout handler. The logout handler
immediately checks `!inactivity` and skips the logic.
This change moves the `inactivity` check out of the logout handler and
into the useEffect condition alongside `isLoggedIn`.
Now, if the user is both logged in and inactive, we skip the logout call
and instead redirect straight to the login page, allowing that page to
handle the redirect logic properly.1 parent c74a40f commit 7a31c02
1 file changed
+6
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
50 | 49 | | |
51 | 50 | | |
52 | | - | |
| 51 | + | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | | - | |
| 59 | + | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | | - | |
| 66 | + | |
68 | 67 | | |
69 | 68 | | |
70 | | - | |
| 69 | + | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | | - | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
| |||
0 commit comments