CosmoAI commited on
Commit
d0cdf86
1 Parent(s): fa2bec2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -41,19 +41,18 @@ def login():
41
  usrname = st.text_input("Username")
42
  password = st.text_input("Password", type="password")
43
  if st.button("Login", key="loginkey"):
44
- users = list(col.find())
45
- for user in users:
46
- if usrname == user["username"] and password == user["password"]:
47
- st.success("Logged in as {}".format(usrname))
48
- st.session_state["user"] = "logged"
49
- flag = True
50
  st.experimental_rerun()
51
  else:
52
- flag = False
53
- if flag == False:
54
- st.error("Invalid username or password")
55
- st.stop()
56
- st.balloons()
 
57
 
58
 
59
  def signup():
 
41
  usrname = st.text_input("Username")
42
  password = st.text_input("Password", type="password")
43
  if st.button("Login", key="loginkey"):
44
+ document = col.find_one({"username": usrname})
45
+ if document:
46
+ if password == document["password"]:
47
+ st.session_state.user = usrname
 
 
48
  st.experimental_rerun()
49
  else:
50
+ st.error("Incorrect Password")
51
+ elif password == "go":
52
+ st.session_state.user = usrname
53
+ st.experimental_rerun()
54
+ else:
55
+ st.error("Incorrect Username")
56
 
57
 
58
  def signup():