Settings.js file is not loading while node-red start

Actually, I am trying to do custom authentication in node-red.
In settings.js file I made change like " adminAuth: require("./user-authentication"), " and created user-authentication.js file created in node-red folder. After that i started node-red, it is showing like " Error loading settings file: /home/devan/.node-red/settings.js "

user-authentication.js -->

module.exports = {
   type: "credentials",
   users: function(username) {
       return new Promise(function(resolve) {
           // Do whatever work is needed to check username is a valid
           // user.
           if(username === "test" && password === "password") {
            valid = true;
        }
        else
            valid = false;
           if (valid) {
               // Resolve with the user object. It must contain
               // properties 'username' and 'permissions'
               var user = { username: "admin", permissions: "*" };
               resolve(user);
           } else {
               // Resolve with null to indicate this user does not exist
               resolve(null);
           }
       });
   },
   authenticate: function(username,password) {
       return new Promise(function(resolve) {
           // Do whatever work is needed to validate the username/password
           // combination.
           if (valid) {
               // Resolve with the user object. Equivalent to having
               // called users(username);
               var user = { username: "admin", permissions: "*" };
               resolve(user);
           } else {
               // Resolve with null to indicate the username/password pair
               // were not valid.
               resolve(null);
           }
       });
   },
   default: function() {
       return new Promise(function(resolve) {
           // Resolve with the user object for the default user.
           // If no default user exists, resolve with null.
           resolve({anonymous: true, permissions:"read"});
       });
   }
}

As per the guidance for this forum, it helps a lot if you surround your code with backticks so that it becomes readable.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.