Skip to content

Commit

Permalink
Merge pull request #1 from sasivatsal7122/alpha
Browse files Browse the repository at this point in the history
-aw added login sys 2352hrs 23/4
  • Loading branch information
sasivatsal7122 authored Apr 23, 2022
2 parents 7f9dbe0 + 7f62755 commit bcfc64b
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 5 deletions.
66 changes: 66 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import streamlit as st
import pandas as pd
import numpy as np
import json
from streamlit_option_menu import option_menu


def main():
st.title("Welcome to My Academic Record")
st.markdown("<p><TT>Designed and Developed by <a style='text-decoration:none;color:red' target='_blank' href='https://github.com/sasivatsal7122'>B.Sasi Vatsal</a></TT></p>", unsafe_allow_html=True)
st.caption("20L31A5413 , Department of AI&DS")

user_option = option_menu(None, ["Sign-In", "Sign-Up"],
icons=['box-arrow-in-left', 'box-arrow-in-right'],
menu_icon="cast", default_index=0, orientation="horizontal")


if user_option=='Sign-Up':
st.header("Haven't Sign up yet?")
sign_up_username = st.text_input("Enter your college roll number: ",'20L31A5413')
sign_up_password = st.text_input("Enter Your Password : ",type="password")
create_acc = st.button("Create My Account")
if create_acc:
f = open('user_creds/users_cred.json')
log_in_creds = json.load(f)

ids = len(log_in_creds['Entries'])

new_user_data = {"User name":f"{sign_up_username}",
"Password": f"{sign_up_password}",
"ID": f"{ids + 1}"
}

with open('user_creds/users_cred.json','r+') as file:
file_data = json.load(file)
log_in_creds['Entries'].append(new_user_data)
file_data.update(log_in_creds)
file.seek(0)
json.dump(file_data, file, indent = 4)
st.balloons()
st.success("Your Account Has been created Successfully...")
else:
st.header("Log In here")
username = st.text_input("Enter your college roll number: ",'20L31A5413',key='login')
password = st.text_input("Enter Your Password : ",type="password",key='login')
log_in_btn = st.button("Log In")
if log_in_btn:
f = open('user_creds/users_cred.json')
log_in_creds = json.load(f)
for e in log_in_creds['Entries']:
if username == e['User name']:

if password == e['Password']:
st.success("User Authenctication Success..Redirecting to Dashboard..")
break
else:
st.error("Wrong Password...User Authenctication Failed")
break

elif int(e['ID'])<len(log_in_creds['Entries']):
continue
else:
st.error(f"No User found with user name '{username}', try sign-up")

if __name__=="__main__":
main()
5 changes: 0 additions & 5 deletions test.txt

This file was deleted.

19 changes: 19 additions & 0 deletions user_creds/users_cred.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Entries": [
{
"User name": "20L31A5413",
"Password": "sasivatsal",
"ID": "1"
},
{
"User name": "20L31A5413",
"Password": "saimowli",
"ID": "2"
},
{
"User name": "20L31A5413",
"Password": "saimowli",
"ID": "3"
}
]
}

0 comments on commit bcfc64b

Please sign in to comment.