Secrets item assignment

I’m trying to create a log in page which can allow users to change their log in credentials but st.secrets won’t allow item assignment, any fix for this?

below is part of the code

import streamlit as st

Retrieve usernames and passwords locally

USERS = st.secrets[“users”]

def stox_charts():
st.title(“My WebApp”)

# Check if user is logged in
if not st.session_state.logged_in:

def login_page():
# Collect user input
username = st.text_input(“Username”)
password = st.text_input(“Password”, type=‘password’)

# Check if username and password are correct
if st.button("Login"):
    if username in USERS and USERS[username] == password:
        st.session_state.logged_in = True
        st.session_state.username = username  # Store the username in session state
        st.error("Incorrect username or password")

def new_page():
st.title(“Welcome to the New Page”)
st.write(f"This is your new page after successful login, {st.session_state.username}.")

# User settings button
if st.button("User Settings"):
    st.session_state.show_user_settings = True

# Logout button
if st.button("Logout"):

def user_settings():
st.title(“User Settings”)
st.write(“Change Username and Password”)

new_username = st.text_input("New Username", value=st.session_state.username)
new_password = st.text_input("New Password", type='password')

# Change username and password
if st.button("Change"):
    global USERS
    if new_username != st.session_state.username and new_username not in USERS:
        # Update username and password in the USERS dictionary
        USERS[new_username] = new_password
        del USERS[st.session_state.username]
        st.session_state.username = new_username
        st.success("Username and password changed successfully")
        # Update secrets
        st.secrets["users"] = USERS
    elif new_username == st.session_state.username:
        st.error("New username cannot be the same as the current username")
        st.error("Username already exists")

def logout():
# Clear session state
st.session_state.logged_in = False
st.session_state.username = None

if ‘logged_in’ not in st.session_state:
st.session_state.logged_in = False
if ‘username’ not in st.session_state:
st.session_state.username = None
if ‘show_user_settings’ not in st.session_state:
st.session_state.show_user_settings = False

if st.session_state.show_user_settings:

Store the credencials in a database that your application can write to.