Spaces:
Running
on
Zero
Running
on
Zero
log user 3
Browse files
app.py
CHANGED
@@ -17,6 +17,8 @@ from db_client import get_user_history, update_user_history, delete_user_history
|
|
17 |
from datetime import datetime
|
18 |
import pytz
|
19 |
from gradio.components import LoginButton
|
|
|
|
|
20 |
|
21 |
load_dotenv()
|
22 |
|
@@ -213,16 +215,13 @@ 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(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"]
|
@@ -239,11 +238,11 @@ with gr.Blocks(title="PixDiet", theme=gr.themes.Ocean()) as demo:
|
|
239 |
)
|
240 |
|
241 |
def get_profile(profile) -> dict:
|
242 |
-
print(profile)
|
243 |
return {
|
244 |
-
"username": profile.username,
|
245 |
-
"profile": profile.profile,
|
246 |
-
"name": profile.name,
|
247 |
}
|
248 |
|
249 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|
|
|
17 |
from datetime import datetime
|
18 |
import pytz
|
19 |
from gradio.components import LoginButton
|
20 |
+
from typing import Optional
|
21 |
+
|
22 |
|
23 |
load_dotenv()
|
24 |
|
|
|
215 |
delete_user_history(USER_ID)
|
216 |
return [], None, ""
|
217 |
|
218 |
+
def user_logged_in(data, user: Optional[gr.OAuthProfile]):
|
219 |
global IS_LOGGED_IN, USER_ID
|
220 |
|
221 |
print("login")
|
222 |
print(data)
|
223 |
|
|
|
|
|
224 |
if user is not None:
|
|
|
225 |
profile = get_profile(user)
|
226 |
print(profile)
|
227 |
USER_ID = profile["username"]
|
|
|
238 |
)
|
239 |
|
240 |
def get_profile(profile) -> dict:
|
241 |
+
print(profile.__dict__)
|
242 |
return {
|
243 |
+
"username": profile.get("username"),
|
244 |
+
"profile": profile.get("profile"),
|
245 |
+
"name": profile.get("name"),
|
246 |
}
|
247 |
|
248 |
send_click_event = send_btn.click(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(
|