liusida / ComfyUI-Login

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

Logout for new UI #23

Open syllebra opened 1 month ago

syllebra commented 1 month ago

Hello and thank you for this extension.

A tiny small issue occurs when we use the new UI: logout button is not visible anymore. I had to do it for my custom node too, it's not very much. If I find time I will mak a PR.

Good luck!

syllebra commented 1 month ago

This is the compatible code in logout.js:

` async setup() { await new Promise(resolve => setTimeout(resolve, 500)); // Delay for 0.5 second before appending the Logout button to the menu, ensuring it is added last.

    function logout(){
        let workflowData = localStorage.getItem('workflow'); // Save the workflow data
        localStorage.clear(); // Clear all items in localStorage
        localStorage.setItem('workflow', workflowData); // Restore the workflow data

        sessionStorage.clear(); // If you use sessionStorage
        window.location.href = "/logout"; 
    }

    // Old interface
    const menu = document.querySelector(".comfy-menu");
    if(menu)
    {
        const logoutButton = document.createElement("button");
        logoutButton.textContent = "Logout";
        logoutButton.onclick = () => {logout()}
        menu.append(logoutButton);
    }

    // New interface
    const side_tb = document.querySelector(".side-tool-bar-end");
    const params_button = document.querySelector(".pi-cog");
    if(side_tb && params_button)
    {
        const logoutButton = params_button.parentElement.cloneNode(true);
        logoutButton.id = "bxRebootButtonNew";
        let shuticon = logoutButton.querySelector(".pi-cog");
        shuticon.classList.remove("pi-cog");
        shuticon.classList.add("pi-sign-out");
        side_tb.append(logoutButton);
        logoutButton.onclick = () => {logout()}
    }       
},`

I made a fork to change UI but can't make PR as I removed parts I don't personnaly use.... https://github.com/syllebra/BilboX-ComfyUI-Login

liusida commented 1 month ago

Hi, syllebra, thanks. But I've just update to the latest version and I saw the Logout button right over there. Am I missing something?

image

syllebra commented 1 month ago

Did you activate the new UI in the settings?

image

liusida commented 1 month ago

Thanks. I saw it.