import streamlit as st from time import sleep from navigation import make_sidebar import yaml import datetime import pytz import os make_sidebar() st.title("Welcome to Job Finder") hide_st_style = """ """ st.markdown(hide_st_style, unsafe_allow_html=True) sign_in, sign_up = st.tabs(["Sign In", "Sign Up"]) with sign_in: username = st.text_input("Username") password = st.text_input("Password", type="password") password = password.strip() if st.button("Sign in", type="primary"): with open('data/users/users.yaml', 'r') as file: config = yaml.safe_load(file) # print(config) if username in list(config.keys()) and password == config[username]["password"]: st.session_state.logged_in = True st.session_state.user=username st.success("Logged in successfully!") sleep(0.5) st.switch_page("pages/page1.py") else: st.error("Incorrect username or password") with sign_up: name = st.text_input("Full name") username = st.text_input("Username",key="signup_user") password = st.text_input("Password", type="password",key="Signup_pass") if st.button("Sign Up", type="primary"): with open('data/users/users.yaml', 'r') as file: config = yaml.safe_load(file) # new_user = {"username":username,"password":password} if username and password and name: if username in list(config.keys()): st.warning("Username is already taken !!") else: user_info = {"password":password, "time":datetime.datetime.now(pytz.timezone('Asia/Kolkata')), "full_name":name, "phone_no":0, "what_app_no":0} config[username] = user_info # Define the folder name folder_name = f'data/users/individuals/{username}' # Create the folder if it doesn't already exist status = {} status[username] = user_info if not os.path.exists(folder_name): os.mkdir(folder_name) #update the user info in global user with open('data/users/users.yaml', 'w') as file: yaml.dump(config, file, default_flow_style=False) #Save user info as status file with open(f'data/users/individuals/{username}/status.yaml', 'w') as file: yaml.dump(status, file, default_flow_style=False) if os.path.exists(folder_name): st.info("Your account has been made successfully.") st.success("Please login to continue") else: st.warning("Provide valid username and password")