Commit e717035
committed
Fix OAuth race conditions, redirect loops, and anonymous token storage
- **Fix Race Condition:** Updated `generic_logged_in` to pass the OAuth token directly to `register_user_from_generic_oauth`. This prevents `TokenExpiredError` caused by attempting to read the token from the database before it has been committed.
- **Fix Redirect Loop:** Updated `OAuthBackend.set` to allow saving tokens for anonymous users if a `provider_user_id` is present in the session. This fixes the "Authentication loop" where a user authenticates successfully but the token isn't saved, causing immediate re-authentication requests.
- **Improve Error Handling:** Modified OAuth login routes to redirect back to the provider (e.g., `google.login`) instead of the local login page upon token errors. This prevents "Token Expired" loops.
Fix OAuth race conditions, redirect loops, and anonymous token storage
- **Fix Race Condition:** Updated `generic_logged_in` to pass the OAuth token directly to `register_user_from_generic_oauth`. This prevents `TokenExpiredError` caused by attempting to read the token from the database before it has been committed.
- **Fix Redirect Loop:** Updated `OAuthBackend.set` to allow saving tokens for anonymous users if a `provider_user_id` is present in the session. This fixes the "Authentication loop" where a user authenticates successfully but the token isn't saved, causing immediate re-authentication requests.
- **Improve Error Handling:** Modified OAuth login routes to redirect back to the provider (e.g., `google.login`) instead of the local login page upon token errors. This prevents "Token Expired" loops.1 parent b67a60b commit e717035
1 file changed
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
195 | 205 | | |
196 | 206 | | |
197 | 207 | | |
| |||
702 | 712 | | |
703 | 713 | | |
704 | 714 | | |
705 | | - | |
| 715 | + | |
| 716 | + | |
706 | 717 | | |
707 | 718 | | |
708 | 719 | | |
| |||
838 | 849 | | |
839 | 850 | | |
840 | 851 | | |
| 852 | + | |
| 853 | + | |
841 | 854 | | |
842 | 855 | | |
843 | 856 | | |
| |||
0 commit comments