diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index 46d0647..5162bff 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -990,7 +990,18 @@ async def process_contact_chat_line(mc, contact, line): password_file = "" password = "" if os.path.isdir(MCCLI_CONFIG_DIR) : + # if a password file exists with node name open it and destroy it password_file = MCCLI_CONFIG_DIR + contact['adv_name'] + ".pass" + if os.path.exists(password_file) : + with open(password_file, "r", encoding="utf-8") as f : + password=f.readline().strip() + os.remove(password_file) + password_file = MCCLI_CONFIG_DIR + contact["public_key"] + ".pass" + with open(password_file, "w", encoding="utf-8") as f : + f.write(password) + + # this is the new correct password file, using pubkey + password_file = MCCLI_CONFIG_DIR + contact["public_key"] + ".pass" if os.path.exists(password_file) : with open(password_file, "r", encoding="utf-8") as f : password=f.readline().strip() @@ -1013,6 +1024,9 @@ async def process_contact_chat_line(mc, contact, line): if line.startswith("forget_password") or line.startswith("fp"): password_file = MCCLI_CONFIG_DIR + contact['adv_name'] + ".pass" + if os.path.exists(password_file): + os.remove(password_file) + password_file = MCCLI_CONFIG_DIR + contact['public_key'] + ".pass" if os.path.exists(password_file): os.remove(password_file) try: