Skip to content

Commit

Permalink
Merge pull request #8 from TogetherCrew/feat/authentication
Browse files Browse the repository at this point in the history
feat: Added login page!
  • Loading branch information
cyri113 authored Mar 11, 2024
2 parents 1485fa9 + be148d6 commit a36342b
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env
__pycache__
environment/*
config.yaml
main.ipynb
31 changes: 25 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

import pandas as pd
import streamlit as st
import yaml
from streamlit_authenticator import Authenticate
from utils.mongo import MongoSingleton
from utils.process_guild_data import process_guild_data
from yaml.loader import SafeLoader


# @st.cache_data
def load_guilds_latest_date_df():
client = MongoSingleton.get_instance().client

Expand Down Expand Up @@ -35,8 +37,25 @@ def load_guilds_latest_date_df():


logging.basicConfig(level=logging.INFO)

st.subheader("MongoDB data Analytics")
load_guilds_latest_date_df()
# df = process_df(df)
# st.dataframe(df, use_container_width=True, hide_index=True)
st.subheader("TogetherCrew's Amin Panel")
with open("config.yaml") as file:
config = yaml.load(file, Loader=SafeLoader)

authenticator = Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
config["preauthorized"],
)
name, authentication_status, username = authenticator.login()

if authentication_status:
authenticator.logout("Logout", "main")
st.write(f"Welcome *{name}*")
# st.title('Some content')
load_guilds_latest_date_df()
elif authentication_status is False:
st.error("Username/password is incorrect")
elif authentication_status is None:
st.warning("Please enter your username and password")
13 changes: 13 additions & 0 deletions config.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
credentials:
usernames:
jsmith:
email: jsmith@gmail.com
name: John Smith
password: abc # To be replaced with hashed password
cookie:
expiry_days: 30
key: random_signature_key # Must be string
name: random_cookie_name
preauthorized:
emails:
- melsby@gmail.com
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
streamlit
streamlit-authenticator
numpy
pandas
matplotlib
Expand Down

0 comments on commit a36342b

Please sign in to comment.