Skip to content

Commit 488f749

Browse files
committed
Remove deprecated usage of self.router.page
1 parent f955c95 commit 488f749

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

reflex_azure_auth/state.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import hashlib
66
import os
77
import secrets
8-
from urllib.parse import urlencode, urlparse
8+
from urllib.parse import parse_qsl, urlencode, urlparse
99

1010
import httpx
1111
import reflex as rx
@@ -141,6 +141,10 @@ def _index_uri(self) -> str:
141141
current_url = urlparse(self.router.url)
142142
return current_url._replace(path="/", query=None, fragment=None).geturl()
143143

144+
def _query_params(self) -> dict[str, str]:
145+
"""Retrieve the query parameters from url since router.page is deprecated."""
146+
return dict(parse_qsl(urlparse(self.router.url).query))
147+
144148
@rx.event
145149
async def redirect_to_login_popup(self):
146150
"""Open a small popup window to initiate the login flow.
@@ -237,8 +241,9 @@ async def auth_callback(self):
237241
and stores tokens for future use.
238242
"""
239243
headers = {"Content-Type": "application/x-www-form-urlencoded"}
240-
code = self.router.page.params.get("code")
241-
app_state = self.router.page.params.get("state")
244+
params = self._query_params()
245+
code = params.get("code")
246+
app_state = params.get("state")
242247
if app_state != self._app_state:
243248
self.error_message = "App state mismatch. Possible CSRF attack."
244249
return rx.toast.error("Authentication error")

0 commit comments

Comments
 (0)