Fix login
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ agent_name = os.getenv('agent_name')
|
|
| 27 |
login_status_key = os.getenv('login_status_key')
|
| 28 |
login_info_key = os.getenv('login_info_key')
|
| 29 |
login_status_key2 = os.getenv('login_status_key2')
|
| 30 |
-
|
| 31 |
|
| 32 |
|
| 33 |
def parse_response(response):
|
|
@@ -267,12 +267,14 @@ def generate_image(main_image, text_description, did, request: gr.Request):
|
|
| 267 |
if not did:
|
| 268 |
did = str(uuid.uuid4())
|
| 269 |
user_id, user_name = check_login_status(request.request.headers)
|
| 270 |
-
|
| 271 |
-
|
|
|
|
|
|
|
| 272 |
if not user_id or not user_name:
|
| 273 |
m = "Please log in to your Hugging Face account to use the features of this application."
|
| 274 |
return gr.Warning(m), did
|
| 275 |
-
user_id = f"{
|
| 276 |
if main_image is None:
|
| 277 |
m = "Please upload both the main image and the background reference image before generating."
|
| 278 |
return gr.Warning(m), did
|
|
@@ -349,9 +351,6 @@ def generate_image(main_image, text_description, did, request: gr.Request):
|
|
| 349 |
user_id=user_id,
|
| 350 |
user_name=user_name
|
| 351 |
)
|
| 352 |
-
print("Query task data:", query_task_data)
|
| 353 |
-
print("Query task msg:", query_task_msg)
|
| 354 |
-
print("Time:", int(time.time()) - start_time)
|
| 355 |
if not query_task_data:
|
| 356 |
return gr.Warning(query_task_msg), did
|
| 357 |
executions = query_task_data.get("executions")
|
|
|
|
| 27 |
login_status_key = os.getenv('login_status_key')
|
| 28 |
login_info_key = os.getenv('login_info_key')
|
| 29 |
login_status_key2 = os.getenv('login_status_key2')
|
| 30 |
+
login_hash_key = os.getenv('login_hash_key')
|
| 31 |
|
| 32 |
|
| 33 |
def parse_response(response):
|
|
|
|
| 267 |
if not did:
|
| 268 |
did = str(uuid.uuid4())
|
| 269 |
user_id, user_name = check_login_status(request.request.headers)
|
| 270 |
+
if not user_id:
|
| 271 |
+
user_id = request.session_hash
|
| 272 |
+
if not user_name:
|
| 273 |
+
user_name = request.session_hash
|
| 274 |
if not user_id or not user_name:
|
| 275 |
m = "Please log in to your Hugging Face account to use the features of this application."
|
| 276 |
return gr.Warning(m), did
|
| 277 |
+
user_id = f"{login_hash_key}{user_id}"
|
| 278 |
if main_image is None:
|
| 279 |
m = "Please upload both the main image and the background reference image before generating."
|
| 280 |
return gr.Warning(m), did
|
|
|
|
| 351 |
user_id=user_id,
|
| 352 |
user_name=user_name
|
| 353 |
)
|
|
|
|
|
|
|
|
|
|
| 354 |
if not query_task_data:
|
| 355 |
return gr.Warning(query_task_msg), did
|
| 356 |
executions = query_task_data.get("executions")
|