Spaces:
Running
on
Zero
Running
on
Zero
log user 2
Browse files
app.py
CHANGED
@@ -213,18 +213,37 @@ with gr.Blocks(title="PixDiet", theme=gr.themes.Ocean()) as demo:
|
|
213 |
delete_user_history(USER_ID)
|
214 |
return [], None, ""
|
215 |
|
216 |
-
def user_logged_in(
|
217 |
global IS_LOGGED_IN, USER_ID
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
if user is not None:
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
222 |
print(f"User logged in: {USER_ID}")
|
223 |
-
return gr.update(visible=False), gr.update(visible=True), gr.update(visible=True)
|
224 |
else:
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
230 |
bot_streaming, [chatbot, image_input], chatbot
|
|
|
213 |
delete_user_history(USER_ID)
|
214 |
return [], None, ""
|
215 |
|
216 |
+
def user_logged_in(data):
|
217 |
global IS_LOGGED_IN, USER_ID
|
218 |
+
|
219 |
+
print("login")
|
220 |
+
print(data)
|
221 |
+
|
222 |
+
user = gr.OAuthProfile
|
223 |
+
|
224 |
if user is not None:
|
225 |
+
|
226 |
+
profile = get_profile(user)
|
227 |
+
print(profile)
|
228 |
+
USER_ID = profile["username"]
|
229 |
print(f"User logged in: {USER_ID}")
|
|
|
230 |
else:
|
231 |
+
USER_ID = "john doe"
|
232 |
+
|
233 |
+
IS_LOGGED_IN = True
|
234 |
+
|
235 |
+
return (
|
236 |
+
gr.update(visible=not IS_LOGGED_IN),
|
237 |
+
gr.update(visible=IS_LOGGED_IN),
|
238 |
+
gr.update(visible=IS_LOGGED_IN)
|
239 |
+
)
|
240 |
+
|
241 |
+
def get_profile(profile) -> dict:
|
242 |
+
return {
|
243 |
+
"username": profile.username,
|
244 |
+
"profile": profile.profile,
|
245 |
+
"name": profile.name,
|
246 |
+
}
|
247 |
|
248 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
249 |
bot_streaming, [chatbot, image_input], chatbot
|