Update add_authemail.py

This commit is contained in:
rapcmia
2023-10-20 20:35:34 +08:00
committed by GitHub
parent 0b823c2c7a
commit 7e12d89db7

View File

@@ -10,17 +10,16 @@ if len(new_email) == 0:
print("\nNo email added, please try again!\n")
exit()
# load the YAML file
yaml_file = "../credentials.yml"
with open(yaml_file, "r") as file:
data = yaml.safe_load(file)
# update the admin password on credentials.yml
# append the email address to credentials.yml
data["preauthorized"]["emails"].append(new_email)
# write the updated data back to the file
with open(yaml_file, "w") as file:
yaml.dump(data, file, Dumper=yaml.RoundTripDumper)
print("Email has been added")
print("Email has been successfully added!")