Spaces:
Paused
Paused
test one-time link (deleted after verification, and helps with the inconsistency issue to not confuse user when logging out)
Browse files
app.py
CHANGED
|
@@ -53,6 +53,9 @@ def hello(profile: gr.OAuthProfile | None, request: gr.Request) -> str:
|
|
| 53 |
if profile is None:
|
| 54 |
return f"# ❌ Not logged in with Hugging Face yet."
|
| 55 |
|
|
|
|
|
|
|
|
|
|
| 56 |
return f"# ✅ Successfully logged in as {profile.username}. User ID: {user_id}"
|
| 57 |
|
| 58 |
with gr.Blocks() as demo:
|
|
@@ -61,14 +64,9 @@ with gr.Blocks() as demo:
|
|
| 61 |
with gr.Row():
|
| 62 |
login_button = gr.LoginButton()
|
| 63 |
|
| 64 |
-
|
| 65 |
m1 = gr.Markdown()
|
| 66 |
demo.load(hello, inputs=None, outputs=m1)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
def check_login_status():
|
| 73 |
try:
|
| 74 |
return login_button.get_session().get("oauth_info", None)
|
|
@@ -84,4 +82,4 @@ with gr.Blocks() as demo:
|
|
| 84 |
|
| 85 |
login_button.click(check_login_wrapper, inputs=None, outputs=m1)
|
| 86 |
|
| 87 |
-
demo.launch()
|
|
|
|
| 53 |
if profile is None:
|
| 54 |
return f"# ❌ Not logged in with Hugging Face yet."
|
| 55 |
|
| 56 |
+
# Remove the token after successful verification
|
| 57 |
+
del user_tokens[int(user_id)]
|
| 58 |
+
|
| 59 |
return f"# ✅ Successfully logged in as {profile.username}. User ID: {user_id}"
|
| 60 |
|
| 61 |
with gr.Blocks() as demo:
|
|
|
|
| 64 |
with gr.Row():
|
| 65 |
login_button = gr.LoginButton()
|
| 66 |
|
|
|
|
| 67 |
m1 = gr.Markdown()
|
| 68 |
demo.load(hello, inputs=None, outputs=m1)
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def check_login_status():
|
| 71 |
try:
|
| 72 |
return login_button.get_session().get("oauth_info", None)
|
|
|
|
| 82 |
|
| 83 |
login_button.click(check_login_wrapper, inputs=None, outputs=m1)
|
| 84 |
|
| 85 |
+
demo.launch()
|