GithubHelp home page GithubHelp logo

Comments (6)

mkhorasani avatar mkhorasani commented on May 20, 2024

Can you please provide a snippet of your code?

from streamlit-authenticator.

jitvimol avatar jitvimol commented on May 20, 2024

Can you please provide a snippet of your code?

Sure Thanks for the help:

I simply add function to reset pwd right after user successfully log in and test logging out.

import streamlit as st
import streamlit_authenticator as stauth
import yaml
from yaml import SafeLoader

with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)

authenticator = stauth.authenticate.Authenticate(
    config['credentials'],
    config['cookie']['name'],
    config['cookie']['key'],
    config['cookie']['expiry_days'],
    config['preauthorized']
)

name, authentication_status, username = authenticator.login('Login', 'main')

if st.session_state["authentication_status"]:
    authenticator.logout('Logout', 'main')
    st.title(f'Welcome *{st.session_state["name"]}*')

    if authentication_status:
        try:
            if authenticator.update_user_details(username, 'Update user details'):
                st.success('Entries updated successfully')
        except Exception as e:
            st.error(e)

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')

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on May 20, 2024

Pleas refer to point 9 of the readme file, once you have updated the config file on memory, you must then commit it to disk.

from streamlit-authenticator.

jitvimol avatar jitvimol commented on May 20, 2024

Pleas refer to point 9 of the readme file, once you have updated the config file on memory, you must then commit it to disk.

Thank you very much. Apologize for not fully understand the library.

from streamlit-authenticator.

colelandolt33 avatar colelandolt33 commented on May 20, 2024
import streamlit as st
import streamlit_authenticator as stauth
import yaml
from yaml import SafeLoader

with open('config.yaml') as file:
    config = yaml.load(file, Loader=SafeLoader)

authenticator = stauth.authenticate.Authenticate(
    config['credentials'],
    config['cookie']['name'],
    config['cookie']['key'],
    config['cookie']['expiry_days'],
    config['preauthorized']
)

name, authentication_status, username = authenticator.login('Login', 'main')

if st.session_state["authentication_status"]:
    authenticator.logout('Logout', 'main')
    st.title(f'Welcome *{st.session_state["name"]}*')

    if authentication_status:
        try:
            if authenticator.update_user_details(username, 'Update user details'):
                st.success('Entries updated successfully')
        except Exception as e:
            st.error(e)

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')

@jitvimol Where did you insert the code from the readme that updates config.yaml within the above code snippet? I'm having trouble implementing this functionality in my streamlit app.

from streamlit-authenticator.

mkhorasani avatar mkhorasani commented on May 20, 2024

Here is the snippet that saves your changes:

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

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.