pradeep4321 commited on
Commit
65aa733
Β·
verified Β·
1 Parent(s): 1bb2d49

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +13 -5
src/app.py CHANGED
@@ -41,18 +41,25 @@ def log_activity(user, action, query, search_type):
41
  pass
42
 
43
  # ==============================
44
- # AUTHENTICATION (MULTI USER)
45
  # ==============================
46
  def login():
47
  st.title("πŸ” Multi-User Login")
48
 
49
  users_json = os.environ.get("USERS") or st.secrets.get("USERS")
50
 
51
- if not users_json:
 
52
  st.error("⚠️ USERS not configured in Hugging Face secrets!")
53
- return
54
 
55
- users = json.loads(users_json)
 
 
 
 
 
 
56
 
57
  username = st.text_input("Username")
58
  password = st.text_input("Password", type="password")
@@ -70,6 +77,7 @@ def login():
70
  log_activity(username, "Login Failed", "-", "-")
71
  st.error("❌ Invalid credentials")
72
 
 
73
  if "authenticated" not in st.session_state:
74
  st.session_state["authenticated"] = False
75
 
@@ -78,7 +86,7 @@ if not st.session_state["authenticated"]:
78
  st.stop()
79
 
80
  # ==============================
81
- # PAGE CONFIG
82
  # ==============================
83
  st.set_page_config(page_title="Multi Search Engine", layout="wide")
84
  st.title("πŸ” Advanced Multi-Search Product Engine")
 
41
  pass
42
 
43
  # ==============================
44
+ # AUTHENTICATION
45
  # ==============================
46
  def login():
47
  st.title("πŸ” Multi-User Login")
48
 
49
  users_json = os.environ.get("USERS") or st.secrets.get("USERS")
50
 
51
+ # βœ… FIX 1: Empty check
52
+ if not users_json or str(users_json).strip() == "":
53
  st.error("⚠️ USERS not configured in Hugging Face secrets!")
54
+ st.stop()
55
 
56
+ # βœ… FIX 2: JSON validation
57
+ try:
58
+ users = json.loads(users_json)
59
+ except Exception:
60
+ st.error("❌ Invalid USERS JSON format!")
61
+ st.code(users_json)
62
+ st.stop()
63
 
64
  username = st.text_input("Username")
65
  password = st.text_input("Password", type="password")
 
77
  log_activity(username, "Login Failed", "-", "-")
78
  st.error("❌ Invalid credentials")
79
 
80
+ # Session control
81
  if "authenticated" not in st.session_state:
82
  st.session_state["authenticated"] = False
83
 
 
86
  st.stop()
87
 
88
  # ==============================
89
+ # UI
90
  # ==============================
91
  st.set_page_config(page_title="Multi Search Engine", layout="wide")
92
  st.title("πŸ” Advanced Multi-Search Product Engine")