Custom user authentication not working

I'm just trying to use Custom user authentication example.

authenticate: function(username,password) {
    return new Promise(function(resolve) {
        // Do whatever work is needed to validate the username/password
        // combination.
        if(username === "test" && password === "password") {
            valid = true;
            valid = false;
        if (valid) {
            // Resolve with the user object. Equivalent to having
            // called users(username);
            var user = { username: "test", permissions: "*" };
        } else {
            // Resolve with null to indicate the username/password pair
            // were not valid.

If I write a wrong password I get this:

But if I write a correct password I get this:

In postman I get the correct answer:

And my browser stores the token:

So is like Node-RED is not storing the token...

is it a bug, or am I doing something wrong?


What does your custom auth's users function look like?

just for understanding,
what does users function do?