Giter Site home page Giter Site logo

Comments (12)

ochapeau avatar ochapeau commented on June 9, 2024 1

I had the same issue when using the function authenticator.reset_password() on a second page of my app as I want my users to have a dedicated page to account management. Calling the authenticator.login() before the authenticator.reset_password() in the code of the second page fixed it for now. I am using streamlit v1.31.1 and streamlit-authenticator v0.3.1. Thank you for the streamlit-authenticator library.

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on June 9, 2024

@ebynapura can you please elaborate by providing a snippet of your code and specify the version of Streamlit-Authenticator you are using?

from streamlit-authenticator.

ebynapura avatar ebynapura commented on June 9, 2024

@ebynapura can you please elaborate by providing a snippet of your code and specify the version of Streamlit-Authenticator you are using?

import streamlit as st
import streamlit_authenticator as stauth
# from streamlit_authenticator import Authenticate
import yaml
from yaml.loader import SafeLoader

st.set_page_config(
   page_title="Acg-DataBoard",
   page_icon="data1.svg",
   layout="wide",
   initial_sidebar_state="collapsed",  # expanded auto
)

# Import the YAML file into your script
with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)


hashed_passwords = stauth.Hasher(['000000', '000000']).generate()
# print(hashed_passwords)

# Create the authenticator object
authenticator = stauth.Authenticate(
    config['credentials'],
    config['cookie']['name'],
    config['cookie']['key'],
    config['cookie']['expiry_days'],
    config['preauthorized']
)


if st.session_state["authentication_status"]:
    authenticator.logout(button_name='退出账户', location='sidebar')
    try:
        if authenticator.reset_password(st.session_state["username"], location='sidebar',
                                        fields={'Form name':'重设密码', 'Current password':'当前密码', 
                                                'New password':'新密码', 'Repeat password': '确认新密码', 'Reset':'重设'}):
            with open('config.yaml', 'w') as file:
                yaml.dump(config, file, default_flow_style=False)
            st.success("已成功修改密码~")
    except Exception as e:
        st.error(e)

    try:
        if authenticator.update_user_details(st.session_state["username"], location='sidebar', 
                                             fields={'Form name':'更新用户信息', 'Field':'更新项', 'Name':'姓名', 
                                                     'Email':'邮箱', 'New value':'更新为', 'Update':'更新'}):
            with open('config.yaml', 'w') as file:
                yaml.dump(config, file, default_flow_style=False)
            st.success('已成功修改信息~')
    except Exception as e:
        st.error(e)

    st.write(f'欢迎: *{st.session_state["name"]}*')
    st.title('Some content')
elif st.session_state["authentication_status"] is False:
    st.error('用户名或密码不正确~')
elif st.session_state["authentication_status"] is None:
    st.warning('请输入您的用户名和密码~')
    authenticator.login(fields={'Form name': '登录'})

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on June 9, 2024

@ebynapura can you please elaborate by providing a snippet of your code and specify the version of Streamlit-Authenticator you are using?

import streamlit as st
import streamlit_authenticator as stauth
# from streamlit_authenticator import Authenticate
import yaml
from yaml.loader import SafeLoader

st.set_page_config(
   page_title="Acg-DataBoard",
   page_icon="data1.svg",
   layout="wide",
   initial_sidebar_state="collapsed",  # expanded auto
)

# Import the YAML file into your script
with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)


hashed_passwords = stauth.Hasher(['000000', '000000']).generate()
# print(hashed_passwords)

# Create the authenticator object
authenticator = stauth.Authenticate(
    config['credentials'],
    config['cookie']['name'],
    config['cookie']['key'],
    config['cookie']['expiry_days'],
    config['preauthorized']
)


if st.session_state["authentication_status"]:
    authenticator.logout(button_name='退出账户', location='sidebar')
    try:
        if authenticator.reset_password(st.session_state["username"], location='sidebar',
                                        fields={'Form name':'重设密码', 'Current password':'当前密码', 
                                                'New password':'新密码', 'Repeat password': '确认新密码', 'Reset':'重设'}):
            with open('config.yaml', 'w') as file:
                yaml.dump(config, file, default_flow_style=False)
            st.success("已成功修改密码~")
    except Exception as e:
        st.error(e)

    try:
        if authenticator.update_user_details(st.session_state["username"], location='sidebar', 
                                             fields={'Form name':'更新用户信息', 'Field':'更新项', 'Name':'姓名', 
                                                     'Email':'邮箱', 'New value':'更新为', 'Update':'更新'}):
            with open('config.yaml', 'w') as file:
                yaml.dump(config, file, default_flow_style=False)
            st.success('已成功修改信息~')
    except Exception as e:
        st.error(e)

    st.write(f'欢迎: *{st.session_state["name"]}*')
    st.title('Some content')
elif st.session_state["authentication_status"] is False:
    st.error('用户名或密码不正确~')
elif st.session_state["authentication_status"] is None:
    st.warning('请输入您的用户名和密码~')
    authenticator.login(fields={'Form name': '登录'})

Which version of Streamlit_authenticator are you using?

from streamlit-authenticator.

ebynapura avatar ebynapura commented on June 9, 2024

@ebynapura can you please elaborate by providing a snippet of your code and specify the version of Streamlit-Authenticator you are using?

Which version of Streamlit_authenticator are you using?

it's 0.3.1

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on June 9, 2024

Dear @ebynapura you have raised an interesting issue, while I would not consider this to be a bug per se, it is indeed an issue that I need to address. The problem is that if you do not invoke the login widget, the max_concurrent_users attribute will not defined, leading to errors for other methods in the class. For your case if you can try to use the login widget before you use the reset password widget. And in the meantime, I will try to push a new release to address this issue.

from streamlit-authenticator.

ebynapura avatar ebynapura commented on June 9, 2024

Dear @ebynapura you have raised an interesting issue, while I would not consider this to be a

ok thx~

from streamlit-authenticator.

xtxxueyan avatar xtxxueyan commented on June 9, 2024

Dear @ebynapura you have raised an interesting issue, while I would not consider this to be a bug per se, it is indeed an issue that I need to address. The problem is that if you do not invoke the login widget, the max_concurrent_users attribute will not defined, leading to errors for other methods in the class. For your case if you can try to use the login widget before you use the reset password widget. And in the meantime, I will try to push a new release to address this issue.

This is a issue, I can't implement the ability to reset my password right now, even after reusing the login component

from streamlit-authenticator.

xtxxueyan avatar xtxxueyan commented on June 9, 2024

Dear @ebynapura you have raised an interesting issue, while I would not consider this to be a bug per se, it is indeed an issue that I need to address. The problem is that if you do not invoke the login widget, the max_concurrent_users attribute will not defined, leading to errors for other methods in the class. For your case if you can try to use the login widget before you use the reset password widget. And in the meantime, I will try to push a new release to address this issue.

When will this be fixed?

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on June 9, 2024

Apologies for the delay, will try to release a new version this weekend.

from streamlit-authenticator.

eurojourney avatar eurojourney commented on June 9, 2024

Apologies for the delay, will try to release a new version this weekend.

Oh, fantastic, looking forward to this fix! I am also getting the same error and the suggestions above did not resolve it... Thank you for this library!

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on June 9, 2024

Dear all this issue has now been fixed in v0.3.2. Thank you for your patience.

from streamlit-authenticator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.