vh_conversation / src /authentication.py
andrewc893's picture
refactor: added typing for python < 3.10
52e114e
Raw
History Blame Contribute Delete
671 Bytes
from pathlib import Path
from typing import Tuple
import yaml
import streamlit_authenticator as stauth
def authenticate(path: Path) -> Tuple[bool, str]:
"""Function tries to authenticate user and returns True if
it succeeds, False if failes along with username"""
with open(path) as file:
config = yaml.load(file, Loader=yaml.SafeLoader)
authenticator = stauth.Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
)
_, authentication_status, username = authenticator.login("Login", "main")
return authentication_status, username