File size: 671 Bytes
f887ca8
52e114e
f887ca8
 
 
 
 
52e114e
f887ca8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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