Skip to content

Commit

Permalink
Upgraded packages
Browse files Browse the repository at this point in the history
1. Upgraded Streamlit to >= 1.18.0
2. Upgraded Extra-Streamlit_Components to >= 0.1.60
  • Loading branch information
mkhorasani committed Sep 8, 2023
1 parent 1f3f53e commit 4b578c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ elif st.session_state["authentication_status"] is None:
* You may use the **reset_password** widget to allow a logged in user to modify their password as shown below.

```python
if authentication_status:
if st.session_state["authentication_status"]:
try:
if authenticator.reset_password(username, 'Reset password'):
if authenticator.reset_password(st.session_state["username"], 'Reset password'):
st.success('Password modified successfully')
except Exception as e:
st.error(e)
Expand Down Expand Up @@ -183,9 +183,9 @@ except Exception as e:
* You may use the **update_user_details** widget to allow a logged in user to update their name and/or email. The widget will automatically save the updated details in both the configuration file and reauthentication cookie.

```python
if authentication_status:
if st.session_state["authentication_status"]:
try:
if authenticator.update_user_details(username, 'Update user details'):
if authenticator.update_user_details(st.session_state["username"], 'Update user details'):
st.success('Entries updated successfully')
except Exception as e:
st.error(e)
Expand Down
6 changes: 3 additions & 3 deletions 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.2.2",
version="0.2.3",
author="Mohammad Khorasani",
author_email="[email protected]",
description="A secure authentication module to validate user credentials in a Streamlit application.",
Expand All @@ -25,7 +25,7 @@
"PyJWT >=2.3.0",
"bcrypt >= 3.1.7",
"PyYAML >= 5.3.1",
"streamlit >= 0.86",
"extra-streamlit-components >= 0.1.55"
"streamlit >= 1.18.0",
"extra-streamlit-components >= 0.1.60"
],
)
32 changes: 10 additions & 22 deletions streamlit_authenticator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
)

# creating a login widget
name, authentication_status, username = authenticator.login('Login', 'main')
if authentication_status:
authenticator.login('Login', 'main')
if st.session_state["authentication_status"]:
authenticator.logout('Logout', 'main')
st.write(f'Welcome *{name}*')
st.write(f'Welcome *{st.session_state["name"]}*')
st.title('Some content')
elif authentication_status is False:
elif st.session_state["authentication_status"] is False:
st.error('Username/password is incorrect')
elif 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 authentication_status:
if st.session_state["authentication_status"]:
try:
if authenticator.reset_password(username, 'Reset password'):
if authenticator.reset_password(st.session_state["username"], 'Reset password'):
st.success('Password modified successfully')
except Exception as e:
st.error(e)
Expand Down Expand Up @@ -73,25 +73,13 @@
st.error(e)

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

# Saving config file
with open('../config.yaml', 'w') as file:
yaml.dump(config, file, default_flow_style=False)

# Alternatively you may use st.session_state['name'], st.session_state['authentication_status'],
# and st.session_state['username'] to access the name, authentication_status, and username.

# if st.session_state['authentication_status']:
# authenticator.logout('Logout', 'main')
# st.write(f'Welcome *{st.session_state["name"]}*')
# st.title('Some content')
# elif st.session_state['authentication_status'] is False:
# st.error('Username/password is incorrect')
# elif st.session_state['authentication_status'] is None:
# st.warning('Please enter your username and password')
yaml.dump(config, file, default_flow_style=False)

0 comments on commit 4b578c7

Please sign in to comment.