Skip to content

Commit

Permalink
v0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhorasani committed Jul 27, 2024
1 parent 61d7adc commit 82fe0bd
Show file tree
Hide file tree
Showing 21 changed files with 1,416 additions and 742 deletions.
128 changes: 92 additions & 36 deletions README.md

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ credentials:
jsmith:
email: jsmith@gmail.com
failed_login_attempts: 0
logged_in: true
logged_in: false
name: John Smith
password: $2b$12$iWlVOac3uujRvTrXDi6wructXftKmo/GyQd6SMu5FmyX306kH.yFO
rbriggs:
Expand All @@ -28,12 +28,6 @@ credentials:
logged_in: false
name: Ross Couper
password: $2b$12$Tir/PbHVmmnt5kgNxgOwMuxNIb2fv2pJ.q71TW8ekvbugCqkye4yu
wdewe:
email: wedw@ew.com
failed_login_attempts: 0
logged_in: false
name: dwew
password: $2b$12$QJBPc7PxaTTBVJ.3cl4KlOPPqYCWVfaHqkk2IsoGDExXhihKZLDgy
pre-authorized:
emails:
- melsby@gmail.com
Binary file modified graphics/register_user.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="streamlit-authenticator",
version="0.3.2",
version="0.3.3",
author="Mohammad Khorasani",
author_email="khorasani.mohammad@gmail.com",
description="A secure authentication module to validate user credentials in a Streamlit application.",
Expand All @@ -25,6 +25,7 @@
"PyJWT >=2.3.0",
"bcrypt >= 3.1.7",
"PyYAML >= 5.3.1",
"captcha >= 0.5.0",
"streamlit >= 1.25.0",
"extra-streamlit-components >= 0.1.70"
],
Expand Down
44 changes: 23 additions & 21 deletions streamlit_authenticator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import streamlit.components.v1 as components
from yaml.loader import SafeLoader

from .authenticate import Authenticate
from .utilities.exceptions import (CredentialsError,
ForgotError,
LoginError,
RegisterError,
ResetError,
UpdateError)
from .views import Authenticate
from .utilities import (CredentialsError,
ForgotError,
Hasher,
LoginError,
RegisterError,
ResetError,
UpdateError)

_RELEASE = True

Expand All @@ -27,6 +28,9 @@
with open('../config.yaml', 'r', encoding='utf-8') as file:
config = yaml.load(file, Loader=SafeLoader)

# Hashing all plain text passwords once
# Hasher.hash_passwords(config['credentials'])

# Creating the authenticator object
authenticator = Authenticate(
config['credentials'],
Expand All @@ -42,26 +46,24 @@
except LoginError as e:
st.error(e)

if st.session_state["authentication_status"]:
if st.session_state['authentication_status']:
authenticator.logout()
st.write(f'Welcome *{st.session_state["name"]}*')
st.title('Some content')
elif st.session_state["authentication_status"] is False:
elif st.session_state['authentication_status'] is False:
st.error('Username/password is incorrect')
elif st.session_state["authentication_status"] is None:
elif st.session_state['authentication_status'] is None:
st.warning('Please enter your username and password')

# Creating a password reset widget
if st.session_state["authentication_status"]:
if st.session_state['authentication_status']:
try:
if authenticator.reset_password(st.session_state["username"]):
if authenticator.reset_password(st.session_state['username']):
st.success('Password modified successfully')
except ResetError as e:
st.error(e)
except CredentialsError as e:
except (CredentialsError, ResetError) as e:
st.error(e)

# # Creating a new user registration widget
# Creating a new user registration widget
try:
(email_of_registered_user,
username_of_registered_user,
Expand All @@ -71,7 +73,7 @@
except RegisterError as e:
st.error(e)

# # Creating a forgot password widget
# Creating a forgot password widget
try:
(username_of_forgotten_password,
email_of_forgotten_password,
Expand All @@ -84,7 +86,7 @@
except ForgotError as e:
st.error(e)

# # Creating a forgot username widget
# Creating a forgot username widget
try:
(username_of_forgotten_username,
email_of_forgotten_username) = authenticator.forgot_username()
Expand All @@ -96,10 +98,10 @@
except ForgotError as e:
st.error(e)

# # Creating an update user details widget
if st.session_state["authentication_status"]:
# Creating an update user details widget
if st.session_state['authentication_status']:
try:
if authenticator.update_user_details(st.session_state["username"]):
if authenticator.update_user_details(st.session_state['username']):
st.success('Entries updated successfully')
except UpdateError as e:
st.error(e)
Expand Down
Loading

0 comments on commit 82fe0bd

Please sign in to comment.