Skip to content

Commit

Permalink
fixing startup
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Sep 24, 2023
1 parent db60333 commit e7907b7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/descope_auth/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

try:
descope_client = DescopeClient(project_id=_descope_id)
except Exception as error:
logging.exception("failed to initialize.")
except AuthException as ex:
print(ex.error_message)


def login_form() -> ui.element:
Expand All @@ -26,6 +26,7 @@ def about() -> Dict[str, Any]:
infos = app.storage.user['descope']
if not infos:
raise Exception('User is not logged in.')
return infos


async def logout() -> None:
Expand Down Expand Up @@ -65,15 +66,15 @@ async def content(client: Client):
token = await ui.run_javascript('return sessionToken && !sdk.isJwtExpired(sessionToken) ? sessionToken : null;')
if token and self._verify(token):
if self.path == '/login':
await self.refresh_token()
await self._refresh()
ui.open('/')
else:
func()
else:
if self.path != '/login':
ui.open('/login')
else:
ui.timer(30, self.refresh_token)
ui.timer(30, self._refresh)
func()

return super().__call__(content)
Expand All @@ -89,7 +90,7 @@ def _verify(token: str) -> bool:
return False

@staticmethod
async def refresh_token() -> None:
async def _refresh() -> None:
await ui.run_javascript('sdk.refresh()', respond=False)


Expand Down

0 comments on commit e7907b7

Please sign in to comment.