Hi all hope all is well.
I've setup a simple user/password authentication receiving stored names a txt file and passwords from a separate txt file for authentication agaisnt the user's input.
I'm struggling to figure out why my authentication process isn't working.
I've setup warning along the code to check variables etc. and to make sure what is typed matches what is read from the files and as far as I can see the code should work fine however it keeps saying that what's typed isn't the same as what is read from the file.
(setup to test the name for now, didn't see why i need to add the extra rules for password if names won't even work yet)
Help would be much appreciated thank you all!
[{"id":"bff02ce1.23867","type":"tab","label":"Authentication Testing","disabled":true,"info":""},{"id":"cf82d211.d074f","type":"function","z":"bff02ce1.23867","name":"","func":"var count = msg.payload.length;\nglobal.set('auth-pass',[]);\n\nfor (var i = 0; i < count; i++){\n global.set('auth-pass['+i+']',msg.payload[i]);\n node.warn('pass is '+global.get('auth-pass['+i+']'));\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":30,"wires":[["a97e4542.a7b0a8"]]},{"id":"3966a8fd.031578","type":"file in","z":"bff02ce1.23867","name":"","filename":"Documents/auth-pass.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":360,"y":30,"wires":[["4c980589.e7653c"]]},{"id":"a97e4542.a7b0a8","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1020,"y":30,"wires":[]},{"id":"be61caf9.93a588","type":"inject","z":"bff02ce1.23867","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":30,"wires":[["3966a8fd.031578"]]},{"id":"65c9fd48.d45614","type":"function","z":"bff02ce1.23867","name":"","func":"var count = msg.payload.length;\nglobal.set('auth-name',[]);\n\nfor(var i = 0; i < count ;i++){\n global.set('auth-name['+i+']',msg.payload[i]);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":90,"wires":[["e54313fe.92ec3"]]},{"id":"7fb6f436.7ee58c","type":"file in","z":"bff02ce1.23867","name":"","filename":"Documents/auth-name.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":360,"y":90,"wires":[["699a86ee.932998"]]},{"id":"e54313fe.92ec3","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1020,"y":90,"wires":[]},{"id":"102a3316.af08fd","type":"inject","z":"bff02ce1.23867","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":90,"wires":[["7fb6f436.7ee58c"]]},{"id":"4c980589.e7653c","type":"split","z":"bff02ce1.23867","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":570,"y":30,"wires":[["14130ad9.c991b5"]]},{"id":"699a86ee.932998","type":"split","z":"bff02ce1.23867","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":570,"y":90,"wires":[["b3b4796c.cc71c8"]]},{"id":"14130ad9.c991b5","type":"join","z":"bff02ce1.23867","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":720,"y":30,"wires":[["cf82d211.d074f"]]},{"id":"b3b4796c.cc71c8","type":"join","z":"bff02ce1.23867","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":90,"wires":[["65c9fd48.d45614"]]},{"id":"ee05d913.760758","type":"ui_text_input","z":"bff02ce1.23867","name":"","label":"","tooltip":"","group":"520f753e.322f2c","order":0,"width":0,"height":0,"passthru":false,"mode":"text","delay":"800","topic":"topic","topicType":"msg","x":80,"y":240,"wires":[["b150c4aa.f4ed48"]]},{"id":"b150c4aa.f4ed48","type":"function","z":"bff02ce1.23867","name":"","func":"msg.payload = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":240,"wires":[["8e891a50.0ff708","76de4152.ff889"]]},{"id":"d4df3b4e.4b8198","type":"ui_text_input","z":"bff02ce1.23867","name":"","label":"","tooltip":"","group":"520f753e.322f2c","order":0,"width":0,"height":0,"passthru":false,"mode":"password","delay":"800","topic":"topic","topicType":"msg","x":100,"y":200,"wires":[["41d8368d.392b08"]]},{"id":"41d8368d.392b08","type":"function","z":"bff02ce1.23867","name":"","func":"msg.payload = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":200,"wires":[["ac6408f5.4860d8","76de4152.ff889"]]},{"id":"8150a429.2e7648","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":370,"wires":[]},{"id":"ac6408f5.4860d8","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":160,"wires":[]},{"id":"8e891a50.0ff708","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":280,"wires":[]},{"id":"dbc3aacb.9b15b8","type":"ui_button","z":"bff02ce1.23867","name":"","group":"520f753e.322f2c","order":2,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"user-pass","payloadType":"global","topic":"topic","topicType":"msg","x":120,"y":370,"wires":[["326c62ab.3a83ae","f2d22e38.d640f"]]},{"id":"76de4152.ff889","type":"join","z":"bff02ce1.23867","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":530,"y":220,"wires":[["f8bd78e0.8f1da8"]]},{"id":"326c62ab.3a83ae","type":"function","z":"bff02ce1.23867","name":"","func":"var name = global.get('user-pass['+0+']');\nnode.warn('new = '+name); \nvar authName= global.get('auth-name['+0+']');\nnode.warn('stored = '+authName);\nif (name == authName){\n msg.payload = 'Valid';\n return[msg,null];\n}\nelse{\n msg.payload = name + ' is not '+authName + ' !!!invalid!!!!'\n return[null,msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":370,"wires":[["8150a429.2e7648"],["8150a429.2e7648"]]},{"id":"f2d22e38.d640f","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":130,"y":410,"wires":[]},{"id":"f8bd78e0.8f1da8","type":"function","z":"bff02ce1.23867","name":"","func":"var count = msg.payload.length;\nglobal.set('user-pass',[]);\n\nfor (var i =0;i<count;i++)\n {\n global.set('user-pass['+i+']',msg.payload[i]);\n node.warn('user-pass = '+global.get('user-pass['+i+']'));\n }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":220,"wires":[["552d313a.67a09"]]},{"id":"5fc3004b.a667e","type":"inject","z":"bff02ce1.23867","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":570,"wires":[["4265a145.9158"]]},{"id":"f18edb9.a530628","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":570,"wires":[]},{"id":"4265a145.9158","type":"function","z":"bff02ce1.23867","name":"","func":"var ar = new Array(2);\nar[0] = global.get('auth-name['+0+']');\nmsg.payload = ar[0].toString();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":570,"wires":[["f18edb9.a530628"]]},{"id":"552d313a.67a09","type":"debug","z":"bff02ce1.23867","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":170,"wires":[]},{"id":"96c29b80.f52698","type":"split","z":"bff02ce1.23867","name":"","splt":"1","spltType":"len","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":570,"y":610,"wires":[["f18edb9.a530628"]]},{"id":"520f753e.322f2c","type":"ui_group","name":"Default","tab":"9322de02.138e9","order":1,"disp":true,"width":"6","collapse":false},{"id":"9322de02.138e9","type":"ui_tab","name":"Testing","icon":"dashboard","disabled":false,"hidden":false}]



. Gonna take me a while to understand your code. your using code I haven't seen before...still on the learning path of this. Half of your code is confusing to me but I'll get it
