liusida / ComfyUI-Login

A custom node that implements basic login for ComfyUI
MIT License
92 stars 12 forks source link

How can I set the password via the command line instead of on the web UI? #19

Closed fanjikang closed 2 months ago

iiiCpu commented 3 months ago

Just my guess POST message to your http://127.0.0.1:8188/login payload username=username&guest_mode=&password=password use CURL or something

fanjikang commented 3 months ago

Just my guess POST message to your http://127.0.0.1:8188/login payload username=username&guest_mode=&password=password use CURL or something

finally, i write this py, modify "login/PASSWORD" `import os import bcrypt import argparse import folder_paths

comfy_dir = os.path.dirname(folder_paths.file) password_path = os.path.join(comfy_dir, "login", "PASSWORD")

default_username = 'admin' default_password = 'admin' parser = argparse.ArgumentParser(description="Authenticate User") parser.add_argument('--username', type=str, help='Username for authentication') parser.add_argument('--password', type=str, help='Password for authentication')

args = parser.parse_args()

username_input = args.username if args.username else default_username password_input = args.password.encode('utf-8') if args.password else default_password.encode('utf-8')

salt = bcrypt.gensalt() hashed_password = bcrypt.hashpw(password_input, salt) with open(password_path, "wb") as file: file.write(hashed_password + b'\n' + username_input.encode('utf-8')) print(f'set password success for user {username_input}')`