Rodja Trappe 1 年之前
父节点
当前提交
73c906fb5b
共有 2 个文件被更改,包括 4 次插入6 次删除
  1. 1 1
      examples/descope_auth/main.py
  2. 3 5
      examples/descope_auth/user.py

+ 1 - 1
examples/descope_auth/main.py

@@ -14,7 +14,7 @@ def login():
 
 @user.page('/')
 def home():
-    ui.markdown(f'```\n{json.dumps(user.about(),indent=2)}\n```')
+    ui.markdown(f'```\n{json.dumps(user.about(), indent=2)}\n```')
     ui.button('Logout', on_click=user.logout)
 
 

+ 3 - 5
examples/descope_auth/user.py

@@ -23,11 +23,9 @@ def login_form() -> ui.element:
 
 def about() -> Dict[str, Any]:
     """Returns the user's Descope profile."""
-    try:
-        return app.storage.user['descope']
-    except AuthException:
-        logging.exception("Unable to load user.")
-        return {}
+    infos = app.storage.user['descope']
+    if not infos:
+        raise Exception('User is not logged in.')
 
 
 async def logout() -> None: