import streamlit as st import bcrypt from db import get_database import time def create_users_collection(): db = get_database() if "users" not in db.list_collection_names(): db.create_collection("users") def signup(data): db = get_database() if db.users.find_one({"username": data["username"]}): return False, "Username already exists" elif db.users.find_one({"email": data["email"]}): return False, "Email already exists" else: hashed = bcrypt.hashpw(data["password"].encode(), bcrypt.gensalt()) data["password"] = hashed db.users.insert_one(data) return True, "Account created successfully!" def login_user(username, password): db = get_database() user = db.users.find_one({"username": username}) if user: stored_password = user["password"] if isinstance(stored_password, str): stored_password = stored_password.encode('utf-8') if bcrypt.checkpw(password.encode(), stored_password): return True, user return False, None def reset_password(email, new_password): db = get_database() user = db.users.find_one({"email": email}) if user: hashed = bcrypt.hashpw(new_password.encode(), bcrypt.gensalt()) db.users.update_one({"email": email}, {"$set": {"password": hashed}}) return True return False def show_login_page(): # Apply custom CSS for modern, animated UI st.markdown(""" """, unsafe_allow_html=True) # Hide Streamlit default elements st.markdown(""" """, unsafe_allow_html=True) # Logo and Header - Using a div container with strict spacing control st.markdown("""
Processing...
', unsafe_allow_html=True) st.markdown('