File size: 1,237 Bytes
7927df4
939b52f
7927df4
38fc6cf
 
 
eb4d2f1
38fc6cf
7927df4
eb4d2f1
303b5f0
2bd90e8
 
 
 
 
 
 
95e1493
 
 
cc23792
7927df4
38fc6cf
7927df4
f408992
7927df4
 
 
 
 
 
 
 
f408992
7927df4
 
f408992
7927df4
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import streamlit as st
import yaml

# Custom imports
from multipage import MultiPage
from authenticator import Hasher, Authenticate
from pages.utils import *

def app():

    DATABASE = db_path('quiz_maker')
    c, conn = db_connect(DATABASE)
    query = "SELECT * FROM users"
    for item in c.execute(query):
        st.write("item")
    conn.commit()
    conn.close()

    yamel_path = db_path('config.yaml')

    with open(yamel_path) as file:
        config = yaml.safe_load(file)

    hashed_passwords = Hasher(config['credentials']['passwords']).generate()

    auth = Authenticate(
        config['credentials']['names'], 
        config['credentials']['usernames'], 
        hashed_passwords,
        config['cookie']['name'], 
        config['cookie']['key'], 
        cookie_expiry_days=30
    )

    auth.login('Login', 'main')

    if st.session_state['authentication_status']:
        auth.logout('Logout', 'main')
        st.title('Some content')
    elif st.session_state['authentication_status'] == False:
        st.error('Username/password is incorrect')
    elif st.session_state['authentication_status'] == None:
        st.warning('Please enter your username and password')