-
Notifications
You must be signed in to change notification settings - Fork 3
/
ibmi-password-flow.json
1 lines (1 loc) · 14.7 KB
/
ibmi-password-flow.json
1
[{"id":"21d562d2.8f2f26","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"7cd3b5f3.88909c","type":"template","z":"21d562d2.8f2f26","name":"NoPWD?","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT NO_PASSWORD_INDICATOR \n FROM QSYS2.USER_INFO \n WHERE AUTHORIZATION_NAME = UCASE({{payload.context.userprf}})\n","output":"str","x":780,"y":480,"wires":[["af7d7447.e9db"]]},{"id":"735a14a6.5b787c","type":"watson-conversation-v1","z":"21d562d2.8f2f26","name":"IBMi-chat","workspaceid":"1ccbda77-1cb2-445d-a6c1-1008f90c1e1b","multiuser":false,"context":true,"empty-payload":false,"default-endpoint":true,"service-endpoint":"","timeout":"","optout-learning":false,"x":320,"y":260,"wires":[["f8dde6d.4ae2a18","e17e7df8.1a71a8"]]},{"id":"e89c60ba.de9cb8","type":"function","z":"21d562d2.8f2f26","name":"Build response","func":"msg.payload = msg.payload.output.text.join(\"\\n\");\nreturn msg;","outputs":1,"noerr":0,"x":1000,"y":360,"wires":[["c2832905.232d1","9a803c4a.818648"]]},{"id":"f8dde6d.4ae2a18","type":"switch","z":"21d562d2.8f2f26","name":"Action?","property":"payload.context.ACTION","propertyType":"msg","rules":[{"t":"eq","v":"CPU","vt":"str"},{"t":"eq","v":"ASP","vt":"str"},{"t":"eq","v":"Send_code","vt":"str"},{"t":"eq","v":"Change_password","vt":"str"},{"t":"eq","v":"Query_user","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":6,"x":382.2381286621094,"y":372.8213806152344,"wires":[["e89c60ba.de9cb8","f6aa653b.e6e5f8"],["e89c60ba.de9cb8","3d2c79cd.da11a6"],["8db18573.e53e08"],["e89c60ba.de9cb8","e700303a.e90b08"],["c082be5d.a7041"],["e89c60ba.de9cb8"]]},{"id":"8db18573.e53e08","type":"function","z":"21d562d2.8f2f26","name":"Generate code and password","func":"// generate new pasword\nvar min = Math.ceil(0);\nvar max = Math.floor(9);\nvar nb1 = (Math.floor(Math.random() * (max - min +1)) + min).toString();\nvar pwd = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5) + nb1 ; \n\nmsg.payload.context.password = pwd ;\n\n// generate a code between 100000 and 999999\nmin = Math.ceil(100000);\nmax = Math.floor(999999);\nmsg.payload.context.code = (Math.floor(Math.random() * (max - min +1)) + min).toString();\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":710,"y":280,"wires":[["e89c60ba.de9cb8","6beeac9b.efef44"]]},{"id":"6beeac9b.efef44","type":"function","z":"21d562d2.8f2f26","name":"Build SMS","func":"// generate SMS content for Twilio gateway\nmsg.payload = msg.payload.context.message + msg.payload.context.code ;\n//msg.topic = '+xxxxxxxxxxx';\n\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":280,"wires":[["8e4c4d75.f8bea8","89862f79.531e7"]]},{"id":"8e4c4d75.f8bea8","type":"debug","z":"21d562d2.8f2f26","name":"Auth Code","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1270,"y":240,"wires":[]},{"id":"25f272b8.efb00e","type":"link in","z":"21d562d2.8f2f26","name":"Conversation-in","links":["b2d5e80a.c7802"],"x":140,"y":120,"wires":[["e7f7bd75.85fef"]],"l":true},{"id":"b2d5e80a.c7802","type":"link out","z":"21d562d2.8f2f26","name":"Conversation-to","links":["25f272b8.efb00e"],"x":1880,"y":300,"wires":[],"l":true},{"id":"e7ca7a23.d69158","type":"function","z":"21d562d2.8f2f26","name":"Extract value","func":"var FirstKey;\n\nfor (var key in msg.payload) {\n if (msg.payload.hasOwnProperty(key)) {\n FirstKey = msg.payload[key];\n break;\n }\n}\nmsg.payload = FirstKey;\nreturn msg;","outputs":1,"noerr":0,"x":1270,"y":180,"wires":[["b2d5e80a.c7802"]]},{"id":"2ec51509.70212a","type":"function","z":"21d562d2.8f2f26","name":"Extract USRPRF values","func":"\nif (msg.payload) {\n if (msg.payload.STATUS == \"*DISABLED\") msg.payload = \"DISABLED (\" + \n msg.payload.SIGN_ON_ATTEMPTS_NOT_VALID + \")\";\n else if (msg.payload.NO_PASSWORD_INDICATOR == \"YES\") msg.payload = \"NO_PASSWORD\" \n else if (msg.payload.SET_PASSWORD_TO_EXPIRE == \"YES\") msg.payload = \"PASSWORD_EXPIRED\";\n else msg.payload = \"200\";\n} else msg.payload = \"500\";\n\nreturn msg;\n\n","outputs":1,"noerr":0,"x":1390,"y":420,"wires":[["b2d5e80a.c7802"]]},{"id":"57daa2af.9e61cc","type":"DB2 for i","z":"21d562d2.8f2f26","mydb":"ce243296.786dc","name":"DSPUSRPRF","arraymode":false,"x":950,"y":420,"wires":[["2ec51509.70212a"]]},{"id":"b47b8a35.d176c","type":"exec","z":"21d562d2.8f2f26","command":"system -i ","addpay":true,"append":"","useSpawn":"false","timer":"120","oldrc":false,"name":"Execute change","x":1540,"y":580,"wires":[["ab04538f.3339b","232724e2.80206c"],["232724e2.80206c"],["232724e2.80206c"]]},{"id":"a1bf8b2e.904898","type":"DB2 for i","z":"21d562d2.8f2f26","mydb":"ce243296.786dc","name":"WRKSYSSTS","arraymode":false,"x":960,"y":180,"wires":[["e7ca7a23.d69158"]]},{"id":"af7d7447.e9db","type":"DB2 for i","z":"21d562d2.8f2f26","mydb":"ce243296.786dc","name":"ChkUSRPRF","arraymode":false,"x":950,"y":480,"wires":[["59c1b140.27aaa"]]},{"id":"af2af475.c35d4","type":"switch","z":"21d562d2.8f2f26","name":"Reset allow?","property":"payload.NO_PASSWORD_INDICATOR","propertyType":"msg","rules":[{"t":"neq","v":"NO","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1150,"y":580,"wires":[["b74a8006.878318"],["d0c9f774.9f2608"]]},{"id":"59c1b140.27aaa","type":"switch","z":"21d562d2.8f2f26","name":"UserFound?","property":"payload.length","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","outputs":2,"x":1150,"y":480,"wires":[["3df5782b.637f3"],["af2af475.c35d4"]]},{"id":"f6aa653b.e6e5f8","type":"template","z":"21d562d2.8f2f26","name":"GetCPU","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT elapsed_cpu_used FROM QSYS2.SYSTEM_STATUS_INFO","output":"str","x":640,"y":180,"wires":[["a1bf8b2e.904898"]]},{"id":"3d2c79cd.da11a6","type":"template","z":"21d562d2.8f2f26","name":"GetASP","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT system_asp_used FROM QSYS2.SYSTEM_STATUS_INFO","output":"str","x":640,"y":220,"wires":[["a1bf8b2e.904898"]]},{"id":"e700303a.e90b08","type":"template","z":"21d562d2.8f2f26","name":"CHGcmd","field":"chgcmd","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\"CHGUSRPRF USRPRF(DENNIS) PASSWORD({{payload.context.password}}) PWDEXP(*YES) STATUS(*ENABLED)\"","output":"str","x":640,"y":480,"wires":[["7cd3b5f3.88909c"]]},{"id":"c082be5d.a7041","type":"template","z":"21d562d2.8f2f26","name":"GetPRFsts","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SELECT STATUS, SIGN_ON_ATTEMPTS_NOT_VALID, PREVIOUS_SIGNON, NO_PASSWORD_INDICATOR, SET_PASSWORD_TO_EXPIRE\n FROM QSYS2.USER_INFO\n WHERE AUTHORIZATION_NAME = UCASE('{{payload.context.userprf}}')","output":"str","x":650,"y":420,"wires":[["57daa2af.9e61cc"]]},{"id":"3df5782b.637f3","type":"change","z":"21d562d2.8f2f26","name":"Return 404","rules":[{"t":"set","p":"payload","pt":"msg","to":"404","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":480,"wires":[["b2d5e80a.c7802"]]},{"id":"d0c9f774.9f2608","type":"change","z":"21d562d2.8f2f26","name":"UpdateAllow","rules":[{"t":"set","p":"payload","pt":"msg","to":"chgcmd","tot":"msg"},{"t":"delete","p":"chgcmd","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1350,"y":580,"wires":[["b47b8a35.d176c"]]},{"id":"b74a8006.878318","type":"change","z":"21d562d2.8f2f26","name":"Return 503","rules":[{"t":"set","p":"payload","pt":"msg","to":"503","tot":"str"},{"t":"delete","p":"chgcmd","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":520,"wires":[["b2d5e80a.c7802"]]},{"id":"ab04538f.3339b","type":"switch","z":"21d562d2.8f2f26","name":"CPC2205","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"CPC2205","vt":"str","case":false},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1700,"y":500,"wires":[["fc9df987.d80a1"],["9bce00d6.b8d468"]]},{"id":"fc9df987.d80a1","type":"change","z":"21d562d2.8f2f26","name":"200","rules":[{"t":"set","p":"payload","pt":"msg","to":"200","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1870,"y":480,"wires":[["b2d5e80a.c7802"]]},{"id":"9bce00d6.b8d468","type":"change","z":"21d562d2.8f2f26","name":"500","rules":[{"t":"set","p":"payload","pt":"msg","to":"500","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1870,"y":520,"wires":[["b2d5e80a.c7802"]]},{"id":"512918c4.2f5878","type":"http in","z":"21d562d2.8f2f26","name":"","url":"/itchat","method":"get","upload":false,"swaggerDoc":"","x":80,"y":60,"wires":[["d114e5b5.ade278"]]},{"id":"25a23dad.384dda","type":"http in","z":"21d562d2.8f2f26","name":"","url":"/itchat","method":"post","upload":false,"swaggerDoc":"","x":110,"y":380,"wires":[["98c72edf.973918","8b4cd5f0.57e93"]]},{"id":"8b4cd5f0.57e93","type":"change","z":"21d562d2.8f2f26","name":"form text","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.text","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":260,"wires":[["735a14a6.5b787c"]]},{"id":"d98743d3.c65148","type":"template","z":"21d562d2.8f2f26","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!DOCTYPE HTML>\n<html>\n <head>\n <title>Simple Live Display</title>\n <script type=\"text/javascript\">\n var ws;\n var wsUri = \"ws:\";\n var loc = window.location;\n console.log(loc);\n if (loc.protocol === \"https:\") { wsUri = \"wss:\"; }\n // This needs to point to the web socket in the Node-RED flow\n // ... in this case it's ws/simple\n wsUri += \"//\" + loc.host + loc.pathname.replace(\"itchat\",\"ws/simple\");\n\n function wsConnect() {\n console.log(\"connect\",wsUri);\n ws = new WebSocket(wsUri);\n //var line = \"\"; // either uncomment this for a building list of messages\n ws.onmessage = function(msg) {\n var line = \"\"; // or uncomment this to overwrite the existing message\n // parse the incoming message as a JSON object\n var data = msg.data;\n //console.log(data);\n // build the output from the topic and payload parts of the object\n line += \"<p>\"+data+\"</p>\";\n // replace the messages div with the new \"line\"\n document.getElementById('messages').innerHTML = line;\n //ws.send(JSON.stringify({data:data}));\n }\n ws.onopen = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"connected\";\n //ws.send(\"Open for data\");\n console.log(\"connected\");\n }\n ws.onclose = function() {\n // update the status div with the connection status\n document.getElementById('status').innerHTML = \"not connected\";\n // in case of lost connection tries to reconnect every 3 secs\n setTimeout(wsConnect,3000);\n }\n }\n \n function doit(m) {\n if (ws) { ws.send(m); }\n }\n </script>\n </head>\n <body onload=\"wsConnect();\" onunload=\"ws.disconnect();\">\nWelcome - {{LOGNAME}}\n<p>\n Running from {{HOME}}\n</p>\n<form method=post>\n Try me: <input type=text name=text maxlength=200 size=100 autofocus>\n</form>\n\n<div style=\"color:green;\">{{payload}}</div>\n<p>\n<div id=messages style=\"color:red;\"></div>","output":"str","x":1420,"y":60,"wires":[["462e75d0.7dd244"]]},{"id":"462e75d0.7dd244","type":"http response","z":"21d562d2.8f2f26","name":"","statusCode":"","headers":{},"x":1870,"y":60,"wires":[]},{"id":"98c72edf.973918","type":"debug","z":"21d562d2.8f2f26","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":330,"y":480,"wires":[]},{"id":"e17e7df8.1a71a8","type":"debug","z":"21d562d2.8f2f26","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":180,"wires":[]},{"id":"c2832905.232d1","type":"websocket out","z":"21d562d2.8f2f26","name":"","server":"95202a23.a39028","client":"","x":1420,"y":360,"wires":[]},{"id":"232724e2.80206c","type":"debug","z":"21d562d2.8f2f26","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1770,"y":580,"wires":[]},{"id":"89862f79.531e7","type":"delay","z":"21d562d2.8f2f26","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1260,"y":280,"wires":[["c2832905.232d1"]]},{"id":"365bcf7c.f3d778","type":"inject","z":"21d562d2.8f2f26","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":580,"wires":[["2fe6ea6d.d47a86"]]},{"id":"13ed7ca4.08e843","type":"DB2 for i","z":"21d562d2.8f2f26","mydb":"ce243296.786dc","name":"SYSTEM_STATUS_INFO","arraymode":false,"x":450,"y":580,"wires":[["c6450585.2ddb28"]]},{"id":"c6450585.2ddb28","type":"debug","z":"21d562d2.8f2f26","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":580,"wires":[]},{"id":"2fe6ea6d.d47a86","type":"template","z":"21d562d2.8f2f26","name":"SYS STS","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"select * from QSYS2.SYSTEM_STATUS_INFO","output":"str","x":240,"y":580,"wires":[["13ed7ca4.08e843"]]},{"id":"b4fe82a3.a9d0d","type":"change","z":"21d562d2.8f2f26","name":"","rules":[{"t":"set","p":"LOGNAME","pt":"msg","to":"LOGNAME","tot":"env"},{"t":"set","p":"HOME","pt":"msg","to":"HOME","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":60,"wires":[["d98743d3.c65148"]]},{"id":"d114e5b5.ade278","type":"change","z":"21d562d2.8f2f26","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":60,"wires":[["b4fe82a3.a9d0d"]]},{"id":"e7f7bd75.85fef","type":"change","z":"21d562d2.8f2f26","name":"","rules":[{"t":"delete","p":"req","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":180,"wires":[["735a14a6.5b787c"]]},{"id":"9a803c4a.818648","type":"switch","z":"21d562d2.8f2f26","name":"","property":"req","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":1230,"y":120,"wires":[["d98743d3.c65148"]]},{"id":"ce243296.786dc","type":"DB2 for i Config","z":"","cnnname":"gcc","db":"*LOCAL","keepalive":true},{"id":"95202a23.a39028","type":"websocket-listener","z":"","path":"/ws/simple","wholemsg":"false"}]