Register the OAuth gate inside the Blocks context
Browse files
app.py
CHANGED
|
@@ -917,8 +917,19 @@ def main() -> None:
|
|
| 917 |
return result
|
| 918 |
|
| 919 |
def controlled_blocks_exit(blocks, exc_type, exc_value, traceback):
|
|
|
|
| 920 |
if blocks is gated_blocks and app_shell is not None:
|
| 921 |
app_shell.__exit__(exc_type, exc_value, traceback)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
return original_blocks_exit(blocks, exc_type, exc_value, traceback)
|
| 923 |
|
| 924 |
gr.Blocks.__enter__ = controlled_blocks_enter
|
|
@@ -965,22 +976,6 @@ def main() -> None:
|
|
| 965 |
|
| 966 |
@wraps(original_launch)
|
| 967 |
def controlled_launch(blocks, *args, **kwargs):
|
| 968 |
-
nonlocal auth_load_configured
|
| 969 |
-
if (
|
| 970 |
-
blocks is gated_blocks
|
| 971 |
-
and auth_gate is not None
|
| 972 |
-
and app_shell is not None
|
| 973 |
-
and not auth_load_configured
|
| 974 |
-
):
|
| 975 |
-
blocks.load(
|
| 976 |
-
auth_visibility,
|
| 977 |
-
inputs=None,
|
| 978 |
-
outputs=[auth_gate, app_shell],
|
| 979 |
-
queue=False,
|
| 980 |
-
api_name=False,
|
| 981 |
-
)
|
| 982 |
-
auth_load_configured = True
|
| 983 |
-
_trace("phase=frontend.auth_gate event=REGISTERED")
|
| 984 |
if not queue_configured:
|
| 985 |
controlled_queue(blocks)
|
| 986 |
kwargs["ssr_mode"] = False
|
|
|
|
| 917 |
return result
|
| 918 |
|
| 919 |
def controlled_blocks_exit(blocks, exc_type, exc_value, traceback):
|
| 920 |
+
nonlocal auth_load_configured
|
| 921 |
if blocks is gated_blocks and app_shell is not None:
|
| 922 |
app_shell.__exit__(exc_type, exc_value, traceback)
|
| 923 |
+
if auth_gate is not None and not auth_load_configured:
|
| 924 |
+
blocks.load(
|
| 925 |
+
auth_visibility,
|
| 926 |
+
inputs=None,
|
| 927 |
+
outputs=[auth_gate, app_shell],
|
| 928 |
+
queue=False,
|
| 929 |
+
api_name=False,
|
| 930 |
+
)
|
| 931 |
+
auth_load_configured = True
|
| 932 |
+
_trace("phase=frontend.auth_gate event=REGISTERED")
|
| 933 |
return original_blocks_exit(blocks, exc_type, exc_value, traceback)
|
| 934 |
|
| 935 |
gr.Blocks.__enter__ = controlled_blocks_enter
|
|
|
|
| 976 |
|
| 977 |
@wraps(original_launch)
|
| 978 |
def controlled_launch(blocks, *args, **kwargs):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 979 |
if not queue_configured:
|
| 980 |
controlled_queue(blocks)
|
| 981 |
kwargs["ssr_mode"] = False
|