Files
hummingbot-dashboard/helpers/edit_authadmin_password.py
Ralph Comia ef3f6642c0 fix/helpers
2023-10-31 12:48:04 +08:00

27 lines
747 B
Python

import streamlit_authenticator as stauth
from ruamel.yaml import YAML
import os
yaml = YAML(typ='safe', pure=True)
# enter admin password or use default t3st01
new_password = input("Enter dashboard password >> ")
new_password = new_password or "t3st01"
# extract the hash password from the List
hash_password = stauth.Hasher([new_password]).generate()[0]
# load the YAML file
yaml_file = "../credentials.yml"
with open(yaml_file, "r") as file:
data = yaml.load(file)
# update the admin password on credentials.yml
data["credentials"]["usernames"]["admin"]["password"] = hash_password
# write the updated data back to the file
with open(yaml_file, "w") as file:
yaml.dump(data, file)
print("Admin password has been updated! ")