akhaliq HF Staff commited on
Commit
2cff369
·
1 Parent(s): 6b5a1a8
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -9817,10 +9817,22 @@ with gr.Blocks(
9817
  # Keep the old deploy method as fallback (if not logged in, user can still use the old method)
9818
  # Optionally, you can keep the old deploy_btn.click for the default method as a secondary button.
9819
 
9820
- # Handle login/logout button clicks to update UI
9821
- # The LoginButton automatically handles OAuth flow, we just need to update UI on click
 
 
 
 
9822
  login_button.click(
9823
- update_ui_for_auth_status,
 
 
 
 
 
 
 
 
9824
  inputs=[],
9825
  outputs=[input, btn, auth_status],
9826
  queue=False
 
9817
  # Keep the old deploy method as fallback (if not logged in, user can still use the old method)
9818
  # Optionally, you can keep the old deploy_btn.click for the default method as a secondary button.
9819
 
9820
+ # Handle authentication state updates
9821
+ # The LoginButton automatically handles OAuth flow and passes profile/token to the function
9822
+ def handle_auth_update(profile: gr.OAuthProfile | None = None, token: gr.OAuthToken | None = None):
9823
+ return update_ui_for_auth_status(profile, token)
9824
+
9825
+ # Update UI when login button is clicked (handles both login and logout)
9826
  login_button.click(
9827
+ handle_auth_update,
9828
+ inputs=[],
9829
+ outputs=[input, btn, auth_status],
9830
+ queue=False
9831
+ )
9832
+
9833
+ # Also update UI when the page loads in case user is already authenticated
9834
+ demo.load(
9835
+ handle_auth_update,
9836
  inputs=[],
9837
  outputs=[input, btn, auth_status],
9838
  queue=False