[ { "id": "665e920cca795df7", "type": "tab", "label": "MULS", "disabled": false, "info": "" }, { "id": "24ea45ad1772c194", "type": "group", "z": "665e920cca795df7", "name": "Intro - Email", "style": { "label": true, "fill": "#e3f3d3", "fill-opacity": "0.5" }, "nodes": [ "998658cc1779c37f", "3e96c9ad7ac7e040", "5d65db1a17172399", "1618be83e8776c89", "4346b596f8a20f3a", "8196d13687d8d4fe", "2b87940d2c61db6d", "39e131f042f8f456" ], "x": 14, "y": 19, "w": 1092, "h": 262 }, { "id": "2728795157ecb5a1", "type": "group", "z": "665e920cca795df7", "name": "New Account", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "ef342147fce699d8", "3cf05340cf7a22cd", "a9d382f1e9a90359", "7a8a0c157c244ef0", "0b5806ddfdef26e0", "33735e80aa3a4ba9", "6e6425b0963d55ac", "fb6ee227bd5d3d60", "b0c9bb5058b48481", "44d397d0b43d7904", "fe57b5e9f6f261fc", "22e2d6932a7bf75c", "22b415c032b32065", "e38ed715d82bd075", "4533746bf9bd6c56", "a0fc0e1426046106", "ad05bbb8b3ebd66f" ], "x": 14, "y": 1099, "w": 1372, "h": 202 }, { "id": "3e6d216dbf2a0833", "type": "group", "z": "665e920cca795df7", "name": "Login", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "76d8771c.4c5b18", "ec9c8fbe2291b8d9", "fed0f4c793c29f14", "5c9e88421cfc47f0", "c9a7565793ec5b46", "1046d0795506e525", "efbb360a0953e754", "687490b1e9d2144d", "b73dcd48e4661a42", "4be5ccd5b062fd8b", "19bb0c1aceed0112", "d09bfd54c769b8bc", "089d8c2ff7f513bd", "36f3090a1eec8582", "ead96491b8dec023", "33afd6e7b9c93348", "5f0286ac7301f3a0", "f22121bb9b23faf0", "2e5da7423d5281ca", "80ade5337767156b", "74cfcd1a11a54516", "e70d55ce178f1a97", "f8295cda4bc8ef32", "b00bc43078b1a729", "ca3620c3feed45e2", "cd8d50e83ab47e81", "109cb4bc8e46ade0", "c45ef762554f2e0d", "dc507e76335c1430", "eb7a73e63176749d", "16c6d1bd2e547974", "54b15251b743c981", "7d68666796bc2e2b", "1efadad7f0f69769", "5d87146588c0e2cb", "99210444c683efb9", "a753f5fb39eed6c1", "43a5c94ad3f1ea9c", "8023edab36b475cd", "0b2d248d89b64672", "b7c718c415f19f7b", "e013ceb5449a44f5", "38e86c01a34d549d", "3d5bd741d664a5d2", "51684d49566056b7", "8b6f192d7fa7c8e1", "898945eda220874c", "0458c6c5015df043", "f77ade98a516b50f", "7716ec922062257a", "8b32e6111c4676eb", "28d681da068bbf0b", "fff742d73bd5bd68", "5294a4074ede5ddb", "ba9a1bd25f9b4695" ], "x": 14, "y": 439, "w": 1392, "h": 642 }, { "id": "5582e0b7d2b0efc4", "type": "group", "z": "665e920cca795df7", "name": "Account", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "e9b66dece7c29b6b", "5b6330732e248865", "5c6ff58051946f04", "d94b4768ba3fecee", "afb7575db0306542", "07063b2f20a14e00", "bcf900f54ec95e41", "b2cf83332f28fb81", "6532082cb07fee9b", "dfafdd31c9594ae6", "484779d81c6fa129", "a8f8071f58de9b68", "50d746116becb07d", "e3b1191aa66c6cd2", "35a5e0abbebd893c", "a44fc16f56918a19", "84584d38a55c661e", "06a4283747f99ffd", "c88dcd345011bead", "9068983f98cf3c94", "13a6ec31df3c2d1f", "beac5465362cd688", "64e749ec85d66e5c", "5f74b446d3e223d8", "d9616b38a2322243", "a7bb3a7ffe3c3873", "89fadb8ea4d690ae", "9d5e12a156cbe6dd", "ebbad3b98280a9f9", "e114f03c40305ca1", "3ef89204f2fc2097", "618813b82d34c25b", "1269b8e25d4490f6", "b364ee1da4b51cb9", "f3facbcda9108ee2", "9659ef05309c1311", "99ab6a24b468dad0", "672b433ec11e9e17", "2b1adf33cca61316", "c9d27a06199c5c56", "d852f2b3ab93ad39", "7a59b29b4dc49c9b", "d1ce7ce00cfcbed3", "bcefeff738b1b85b", "7b814871ab916ec5", "45a6e1b70101da3d", "6fbe93cdb7209abc", "c57302da4ee53cb1", "02fe774de2160772", "d47604c1f266e61b", "d6bf1b639f3dbac0", "bbf46b0ed5727811", "46c5ebccf05a7d75", "b9bf9e288df0d71b", "9ecffb3948144e55", "f62511be2c967bce", "152be4649cf73f00" ], "x": 14, "y": 1579, "w": 1372, "h": 582 }, { "id": "7b26426dcc5af3d1", "type": "group", "z": "665e920cca795df7", "name": "Account Recovery", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "ebf06ebc2e218c6d", "3e5f0d93ebee7a01", "7eb72b7912f3dc67", "7c6a04ab7699c0f1", "16baf3917e6b540b", "eb16292409df87d1", "22e21411782f5db5", "4b5a06c88fb9185c", "20544c1dd87f617e", "e8adc61cd834c40d", "57c79b7c52d7ec72", "e0ce03479bcb45b9", "5e09b65ab3a367a2", "8958446cb99e5abc", "58052a3c8d3ded4a", "70129261bc9dbe85", "13a4c5f01a62d9d4", "20233496ddb3b129", "ffc054e8d485e58e", "a4515fe413e998b8", "de7243b5a17a049e" ], "x": 14, "y": 1319, "w": 1372, "h": 242 }, { "id": "7f4066b5a86a06c0", "type": "group", "z": "665e920cca795df7", "name": "Admin", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "8b1a3ba309939d68", "6a96a2f61d41a5df", "b69c66a718669d38", "3d2597702d94810a", "be5292d5e065decf", "b7b2d0d2443909dd", "b229cc1b1267098f", "0b56d3ca1a44a502", "53a667e1f0e49824", "4cdbaca3dd65d3df", "e16c049054b50c0f", "c190e05ace9bd4e0", "bff2cf80354f6274", "39df5ad5e775b340", "19295afe8d6f16cf", "cedf95caf505837e", "09dd726244181888", "4d686702d15821b8", "cf70eeeac4eeb453", "60517d4c5eb0ea3b", "ef82643f4ce48dfb", "e3f6e839411b862a", "760df7be0e91b1b7", "749f325fc285f8a0", "692d93619ad1760d", "1232d57e1ee6738d", "d849457489f03c43", "a30b2258aa619d39", "3837523c2fbc3913", "e5f88c7039988043", "874d03e55576b320", "f371f7073daed926", "b85660bbaa59143f", "fdadde907d2ccd04", "829b6a38194816ab", "b3b68b81ab81ee1c", "556a7ff6edf3abc7", "b16235d4fd175118", "d33d69103a8d833e", "4e29658693b680e7", "95f0c6145665b641", "8e6b2fbedaf9f779", "13e040673443d5ab", "86e703b77ce6037d", "add62737dbb5a787", "2508612c222daa77", "dc89563da1a69c88", "1f4c57c7b94c6cba", "38f8a20df7659acf", "7e03441d353c5cdb", "9b856e493b373db9", "6eed64ec10a53d48", "b8996025fe824c8b", "717a680cf7b099b4", "c50b99dbafae42cf", "9e093028cd88b473", "bea388cc2090053a", "42e24d946b45716a", "6a682b3f32705976", "2803a8aa6f900add", "b8b39bdd437cc391", "c0a76f2f53cb773a", "df652bc2903db105", "72e81bc851bed530", "3b92ee60fd73213a", "4765a984bb3fe5f4", "7c6d5c44c16d806a", "c6d15893659de90e", "768ec9889a3fa9c4", "cfb87687ae62b688", "b2111a0bac8b432c", "5fedd441611656e2", "a97536cfb74f066f", "abaccc336ca1abe1", "89e665156db7bb96", "8e3017276d094dc2", "edb9e9ec6363f17a", "22a5ca311d37efe6", "cfe7e3def607a084", "567bbcd41053d5f4", "b2295c412e19509f", "46b15d4ecebba222", "7d3c0fbeb85edcbe", "a98cd8cad8b7a555", "a44cb5a9766ad758", "2a09a2d7b3dfae3b", "c1fee42ba43aa8f7", "8d4dd41316215700", "1bd6545b19dcb9e4", "8812453143c547ac", "f94f2961831ae700", "d8bd186e8471f5c0", "bb15ccbd5234681f", "e4582b4aeab64608", "357ea85512f46ffd", "27a26fc8fcefc195", "76e520ee7aa09625", "315a81f83240dc1b", "19b1a4821660a0c2", "2f18b91432937f14", "d1b859d356ebf858", "2622b0747be31ef2", "794bf4721284e6da", "ef949552aab281c6", "afcc8b30d5d0779d", "84018a4e16ba25d3", "ac6af2069acff936", "73763d67ee7418cd", "b0dd4065f2570aa5", "5da54d6b0e5fb715", "a38b8c64e81328bd", "3a50847695423c17", "e3e4160d4d060109", "609075148e8d6156", "f5d4d11e49df0ac2", "9e8b701e4d8d9b71", "f3f8b792aa6cca53", "29e6fae85c7bd9e4", "dc72470f226e363b", "fc20266d8615f014", "2df4eb2550821d38", "e135dfbceda48a37", "3cd3e0a3f8ba2ebc", "903e919ea1e8c12d", "c0e4757fbf245ca7", "5d29a0a5d53555ab", "eee84f32924154a4", "7b0e31885e56d55d", "3b97d7edfcb41a39", "0e72439280702488", "df3ebb2a55542494", "d5185aadb4aa24cf", "3b01373bf7149497", "f2a5c454e9b5322a", "04cb596958a24c45", "3fe082c1d5759802", "4cdc725d19c730c0" ], "x": 14, "y": 2179, "w": 1452, "h": 1202 }, { "id": "9999f11f35f2d72d", "type": "group", "z": "665e920cca795df7", "name": "Automation", "style": { "fill": "#e3f3d3", "fill-opacity": "0.5", "label": true }, "nodes": [ "d5f9e906cad8072d", "2ac2062c48c17b5e", "91388ede8f6ae3d1", "0be44e8787367d0f", "3e656dd98e982e1a", "7228c5e32fd6d0dd", "cc0fb0628467acde", "56c2c41b35e9240a", "7cb5f75829fd1b30", "55d11b9f94f4add4", "e1fd9852384837a4", "a026144815c1fb59", "c1f20c1e7f6384e5", "f7ec73f6d887b66c", "9cd18365033fde3a" ], "x": 14, "y": 3399, "w": 1152, "h": 282 }, { "id": "a89307a8db096479", "type": "group", "z": "665e920cca795df7", "name": "Startup", "style": { "fill": "#ffbfbf", "fill-opacity": "0.25", "label": true }, "nodes": [ "f07163f79c764fbe", "2fb231241c6aaa54", "0e4dc2b9bbd0550c", "ab237985603dccdb", "ec27ef518271709d", "3fca8a532ffa3ea5", "63aebc9bd72c5e14", "88a55a5c51ebfa91", "3cb4d716e31f4b65", "d2d121d0754878ee", "394e2b5c929c0b83", "ae648d9f17fe7f97", "14e682d681c51d30", "c2b4637397048e51", "cacf2070b1f7fafd", "69cea5dd7286314b", "cd7fb8afa0f15a67", "4b0b6adcd85edcf1", "b22dde67c3b464ac", "2849dad2b983b2a9", "807f50c238575f6f", "90471faa7e307334", "2d0575b580beb6e7", "bb685987ecd19262", "b7b0ba0b444fdcdd", "dede0f69e5d35dd2", "2a1f1724aa93eef6", "349930bac63f4f32", "329ba949f0a48147" ], "x": 14, "y": 3699, "w": 1412, "h": 322 }, { "id": "e47b43ae86e94cd7", "type": "group", "z": "665e920cca795df7", "name": "Home", "style": { "fill": "#e3f3d3", "fill-opacity": "0.5", "label": true }, "nodes": [ "ac4a6a0d03e4d11b", "344df62c29ce0de1" ], "x": 14, "y": 299, "w": 192, "h": 122 }, { "id": "76d8771c.4c5b18", "type": "ui_form", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Form for entering userName and userPassword", "label": "", "group": "f5f7cada415a15e8", "order": 2, "width": 6, "height": 3, "options": [ { "label": "Username", "value": "Username", "type": "text", "required": false, "rows": null }, { "label": "Password", "value": "Password", "type": "password", "required": false, "rows": null } ], "formValue": { "Username": "", "Password": "" }, "payload": "", "submit": "LOGIN", "cancel": "", "topic": "", "topicType": "str", "splitLayout": false, "x": 240, "y": 720, "wires": [ [ "f8295cda4bc8ef32" ] ] }, { "id": "ec9c8fbe2291b8d9", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 520, "wires": [] }, { "id": "fed0f4c793c29f14", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "AuthLoginCredentials", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst authSettings = global.get('authSettings');\nconst params = msg.params || {};\n\n\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n\n\n//clean up AuthLoginCredentials so it does not overflow.\n//Set length of AuthLoginCredentials object, \n//Rather how many supported users at a time from authSettings.muiLogin.maxSocketips\nvar AuthLoginCredentialsMaxLength = authSettings.muiLogin.maxSocketips;\n//get keys AuthLoginCredentials object \nvar AuthLoginCredentialsKeys = Object.keys(AuthLoginCredentials);\n//get length of AuthLoginCredentials object \nvar AuthLoginCredentialsLength = AuthLoginCredentialsKeys.length;\n//remove 2 items from Credentials if > AuthLoginCredentialsMaxLength\nif (AuthLoginCredentialsLength > AuthLoginCredentialsMaxLength)\n{ \n delete AuthLoginCredentials[AuthLoginCredentialsKeys[0]];\n delete AuthLoginCredentials[AuthLoginCredentialsKeys[1]];\n}\n\n\n\n//set AuthLoginCredentials to users accessing this page\nif (!AuthLoginCredentials[socketid])\n{\n AuthLoginCredentials[socketid] = {};\n AuthLoginCredentials[socketid]['ip'] = socketip;\n}\nelse\n{\n AuthLoginCredentials[socketid]['ip'] = socketip;\n}\n\n\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\n\n//AuthLoginCredentials = global.get('AuthLoginCredentials');\n\n//msg.AuthLoginCredentials = AuthLoginCredentials;\n//msg.AuthLoginCredentialsKeys = AuthLoginCredentialsKeys;\n//msg.AuthLoginCredentialsMaxLength = AuthLoginCredentialsMaxLength;\n//msg.AuthLoginCredentialsLength = AuthLoginCredentialsLength;\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 520, "wires": [ [ "ec9c8fbe2291b8d9" ] ] }, { "id": "5c9e88421cfc47f0", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "msg.name == Login [only track users that come to Login]", "property": "name", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Login", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 450, "y": 520, "wires": [ [ "c9a7565793ec5b46" ] ] }, { "id": "c9a7565793ec5b46", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 750, "y": 520, "wires": [ [ "fed0f4c793c29f14" ] ] }, { "id": "1046d0795506e525", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "msg.payload == lost", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "lost", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 340, "y": 640, "wires": [ [ "efbb360a0953e754" ] ] }, { "id": "efbb360a0953e754", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 750, "y": 640, "wires": [ [ "33afd6e7b9c93348", "687490b1e9d2144d" ] ] }, { "id": "687490b1e9d2144d", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Remove Credentials", "func": "const socketid = msg.socketid;\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\nvar admingSelections = global.get('admingSelections')||{};\n//RemoveAuthLoginCredentials when user is lost\ndelete AuthLoginCredentials[socketid];\ndelete admingSelections[socketid];\n\n\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nglobal.set('admingSelections', admingSelections);\n\n//AuthLoginCredentials = global.get('AuthLoginCredentials');\n//msg.AuthLoginCredentials = AuthLoginCredentials;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 640, "wires": [ [ "b73dcd48e4661a42" ] ] }, { "id": "b73dcd48e4661a42", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 640, "wires": [] }, { "id": "4be5ccd5b062fd8b", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "msg.payload == connect", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "connect", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 350, "y": 560, "wires": [ [ "19bb0c1aceed0112" ] ] }, { "id": "19bb0c1aceed0112", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 750, "y": 560, "wires": [ [ "d09bfd54c769b8bc", "5294a4074ede5ddb" ] ] }, { "id": "d09bfd54c769b8bc", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 330, "y": 600, "wires": [ [ "089d8c2ff7f513bd" ] ] }, { "id": "089d8c2ff7f513bd", "type": "moment", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 780, "y": 600, "wires": [ [ "36f3090a1eec8582" ] ] }, { "id": "36f3090a1eec8582", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "MUI LOG [connect]", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst humanTimestamp = msg.humanTimestamp;\nconst conectionType = msg.payload;\nconst newLineInLog = conectionType + ' | ' + humanTimestamp + ` | IP - ` + socketip + ` | socket - ` + socketid;\nconst authSettings = global.get('authSettings')||{};\n\n//Get muiLog else create it\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n\n\n\n\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\n\n\nglobal.set('muiLog', muiLog);\n//muiLog = global.get('muiLog');\n//msg.muiLog = muiLog;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1090, "y": 600, "wires": [ [ "ead96491b8dec023" ] ] }, { "id": "ead96491b8dec023", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 600, "wires": [] }, { "id": "33afd6e7b9c93348", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 330, "y": 680, "wires": [ [ "5f0286ac7301f3a0" ] ] }, { "id": "5f0286ac7301f3a0", "type": "moment", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 780, "y": 680, "wires": [ [ "f22121bb9b23faf0" ] ] }, { "id": "f22121bb9b23faf0", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "MUI LOG [lost]", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst humanTimestamp = msg.humanTimestamp;\nconst conectionType = msg.payload;\nconst newLineInLog = conectionType + ' | ' + humanTimestamp + ` | IP - ` + socketip + ` | socket - ` + socketid;\nconst authSettings = global.get('authSettings')||{};\n\n\n//Get muiLog else create it\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\n\n\nglobal.set('muiLog', muiLog);\n//muiLog = global.get('muiLog');\n//msg.muiLog = muiLog;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1100, "y": 680, "wires": [ [ "2e5da7423d5281ca" ] ] }, { "id": "2e5da7423d5281ca", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 680, "wires": [] }, { "id": "80ade5337767156b", "type": "ui_ui_control", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "events": "change", "x": 120, "y": 520, "wires": [ [ "5c9e88421cfc47f0" ] ] }, { "id": "74cfcd1a11a54516", "type": "ui_ui_control", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "events": "all", "x": 120, "y": 600, "wires": [ [ "4be5ccd5b062fd8b", "1046d0795506e525" ] ] }, { "id": "e70d55ce178f1a97", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 720, "wires": [] }, { "id": "f8295cda4bc8ef32", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "add userName and userPassword to AuthLoginCredentials", "func": "const socketid = msg.socketid;\nconst userName = msg.payload.Username;\nconst userPassword = msg.payload.Password;\nvar error = false;\nvar errorMsg;\n\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n\n\n\n//add userName and userPassword to AuthLoginCredentials.socketid\nif (AuthLoginCredentials[socketid])\n{\n AuthLoginCredentials[socketid]['userName'] = userName;\n AuthLoginCredentials[socketid]['userPassword'] = userPassword;\n}\nelse\n{\n error = true;\n errorMsg = 'socketid:' + socketid + ' not found in AuthLoginCredentials, User sat idle too long or too many users are trying to login.'\n}\n\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\n\n//AuthLoginCredentials = global.get('AuthLoginCredentials');\n\n//msg.AuthLoginCredentials = AuthLoginCredentials;\nmsg.error = error;\nmsg.errorMsg = errorMsg;\n \nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 660, "y": 720, "wires": [ [ "e70d55ce178f1a97", "ca3620c3feed45e2" ] ] }, { "id": "b00bc43078b1a729", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Is AuthLoginCredentials user in authUsers Object", "func": "const socketid = msg.socketid;\nconst AuthLoginCredentials = global.get('AuthLoginCredentials');\nconst authUsers = global.get('authUsers');\nconst userName = AuthLoginCredentials[socketid].userName;\nvar userNameCheck = false;\n\n\n//check that userName is in authUsers\nif (authUsers.hasOwnProperty(userName) ) {\nuserNameCheck = true;\n}\n\nmsg.userName = userName;\nmsg.userNameCheck = userNameCheck;\n\n\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 550, "y": 800, "wires": [ [ "109cb4bc8e46ade0" ] ] }, { "id": "ca3620c3feed45e2", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 150, "y": 760, "wires": [ [ "16c6d1bd2e547974" ] ] }, { "id": "cd8d50e83ab47e81", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "userPassword and authUsers Hash", "func": "const socketid = msg.socketid;\nconst AuthLoginCredentials = global.get('AuthLoginCredentials');\nconst authUsers = global.get('authUsers');\n\nmsg.authUsersPasswordHash = authUsers[AuthLoginCredentials[socketid].userName].password;\nmsg.AuthLoginCredentialsPassword = AuthLoginCredentials[socketid].userPassword;\n\nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 200, "y": 880, "wires": [ [ "c45ef762554f2e0d" ] ] }, { "id": "109cb4bc8e46ade0", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "userNameCheck false/true", "property": "userNameCheck", "propertyType": "msg", "rules": [ { "t": "false" }, { "t": "true" } ], "checkall": "false", "repair": false, "outputs": 2, "x": 180, "y": 840, "wires": [ [ "eb7a73e63176749d" ], [ "cd8d50e83ab47e81" ] ] }, { "id": "c45ef762554f2e0d", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "action": "verify", "field": "AuthLoginCredentialsPassword", "hash": "authUsersPasswordHash", "rounds": "4", "x": 130, "y": 920, "wires": [ [ "dc507e76335c1430" ] ] }, { "id": "dc507e76335c1430", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "userPasswordCheck false/true", "property": "match", "propertyType": "msg", "rules": [ { "t": "false" }, { "t": "true" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 190, "y": 960, "wires": [ [ "eb7a73e63176749d" ], [ "a753f5fb39eed6c1" ] ] }, { "id": "eb7a73e63176749d", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Failed Login counter & MUI LOG", "func": "const socketid = msg.socketid;\nconst AuthLoginCredentials = global.get('AuthLoginCredentials');\nconst socketip = AuthLoginCredentials[socketid]['ip'];\nconst userName = msg.userName;\nconst userNameCheck = msg.userNameCheck;\nconst userPasswordCheck = msg.match;\nconst humanTimestamp = msg.humanTimestamp;\n\n//Get MUIlOG else create it\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//Get failedLoginTimmer else create it\nvar failedLoginTimmer = global.get('failedLoginTimmer')||{};\n\n\n//Check if userName exzists and is found\nif (userNameCheck === false)\n{\n var newLineInLog = 'Relative URL: /ui/#!/1 | ' + humanTimestamp + ` | IP - ` + socketip + ` | ` + `Login FAIL - Incorrect Name: ` + userName + ` | socket - ` + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n \n if (!failedLoginTimmer[socketip])\n {\n failedLoginTimmer[socketip] = {};\n failedLoginTimmer[socketip]['socketid'] = socketid;\n failedLoginTimmer[socketip]['userNameCheck'] = userNameCheck;\n failedLoginTimmer[socketip]['userName'] = userName;\n failedLoginTimmer[socketip]['failedattempts'] = 1;\n \n }\n else\n {\n failedLoginTimmer[socketip]['socketid'] = socketid;\n failedLoginTimmer[socketip]['userNameCheck'] = userNameCheck;\n failedLoginTimmer[socketip]['userName'] = userName;\n failedLoginTimmer[socketip]['failedattempts'] = failedLoginTimmer[socketip]['failedattempts'] + 1;\n }\n}\nelse if (userPasswordCheck === false)\n{\n newLineInLog = 'Relative URL: /ui/#!/1 | ' + humanTimestamp + ` | IP - ` + socketip + ` | ` + `Login FAIL - Incorrect Password | socket - ` + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n \n if (!failedLoginTimmer[socketip])\n {\n failedLoginTimmer[socketip] = {};\n failedLoginTimmer[socketip]['socketid'] = socketid;\n failedLoginTimmer[socketip]['userNameCheck'] = userNameCheck;\n failedLoginTimmer[socketip]['userName'] = userName;\n failedLoginTimmer[socketip]['userPasswordCheck'] = userPasswordCheck;\n failedLoginTimmer[socketip]['failedattempts'] = 1;\n \n }\n else\n {\n failedLoginTimmer[socketip]['socketid'] = socketid;\n failedLoginTimmer[socketip]['userNameCheck'] = userNameCheck;\n failedLoginTimmer[socketip]['userName'] = userName;\n failedLoginTimmer[socketip]['userPasswordCheck'] = userPasswordCheck;\n failedLoginTimmer[socketip]['failedattempts'] = failedLoginTimmer[socketip]['failedattempts'] + 1;\n }\n}\n\n\n\nglobal.set('muiLog', muiLog);\n\n//muiLog = global.get('muiLog');\n//msg.muiLog = muiLog;\n\nglobal.set('failedLoginTimmer', failedLoginTimmer);\n\nfailedLoginTimmer = global.get('failedLoginTimmer');\nvar failedattempts = failedLoginTimmer[socketip]['failedattempts'];\n\nmsg.failedLoginTimmer = failedLoginTimmer;\nmsg.failedattempts = failedattempts\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 610, "y": 840, "wires": [ [ "5d87146588c0e2cb" ] ] }, { "id": "16c6d1bd2e547974", "type": "moment", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 360, "y": 760, "wires": [ [ "54b15251b743c981" ] ] }, { "id": "54b15251b743c981", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Failed Login Delay", "func": "const socketid = msg.socketid;\nconst AuthLoginCredentials = global.get('AuthLoginCredentials');\nconst socketip = AuthLoginCredentials[socketid]['ip']||'0.0.0.0';\n\n//Get failedLoginTimmer else create it\nvar failedLoginTimmer = global.get('failedLoginTimmer')||{};\n\n\n//clean up failedLoginTimmer so it does not overflow.\n//rather how many ip's to store at any given time\nvar failedLoginTimmerMaxLength = 31557600;\n//get keys failedLoginTimmer object \nvar failedLoginTimmerKeys = Object.keys(failedLoginTimmer);\n//get length of failedLoginTimmer object \nvar failedLoginTimmerLength = failedLoginTimmerKeys.length;\n//remove 2 items from failedLoginTimmer if > failedLoginTimmerMaxLength\nif (failedLoginTimmerLength > failedLoginTimmerMaxLength)\n{ \n delete failedLoginTimmer[failedLoginTimmerKeys[0]];\n delete failedLoginTimmer[failedLoginTimmerKeys[1]];\n}\n\n//check if ip has been added to timmer\nif (!failedLoginTimmer[socketip])\n{\n msg.delay = 1000;\n //msg.rate = 1000;\n msg.failedattempts = 1;\n return msg;\n}\nelse\n{\n msg.delay = failedLoginTimmer[socketip]['failedattempts'] * 1000;\n //msg.rate = failedLoginTimmer[socketip]['failedattempts'] * 1000;\n msg.failedattempts = failedLoginTimmer[socketip]['failedattempts'];\n return msg;\n}\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 760, "wires": [ [ "7d68666796bc2e2b", "898945eda220874c" ] ] }, { "id": "7d68666796bc2e2b", "type": "change", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 130, "y": 800, "wires": [ [ "43a5c94ad3f1ea9c" ] ] }, { "id": "1efadad7f0f69769", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "LOGIN FAILURE warning", "func": "\nmsg.topic = `LOGIN FAILURE`;\nmsg.payload = `Username or Password Incorrect`;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1070, "y": 880, "wires": [ [ "b7c718c415f19f7b" ] ] }, { "id": "5d87146588c0e2cb", "type": "switch", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "failedattempts < 5, else", "property": "failedattempts", "propertyType": "msg", "rules": [ { "t": "lte", "v": "5", "vt": "num" }, { "t": "else" } ], "checkall": "false", "repair": false, "outputs": 2, "x": 630, "y": 880, "wires": [ [ "1efadad7f0f69769" ], [ "99210444c683efb9" ] ] }, { "id": "99210444c683efb9", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "LOGIN FAILURE warning", "func": "\nmsg.topic = `LOGIN FAILURE`;\nmsg.payload = `Username or Password Incorrect`;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 630, "y": 920, "wires": [ [ "3d5bd741d664a5d2" ] ] }, { "id": "a753f5fb39eed6c1", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Login Success: MUI LOG", "func": "const socketid = msg.socketid;\nvar AuthLoginCredentials = global.get('AuthLoginCredentials');\nconst socketip = AuthLoginCredentials[socketid]['ip'];\nconst userName = msg.userName;\nconst humanTimestamp = msg.humanTimestamp;\nconst authUsers = global.get('authUsers');\nconst authSettings = global.get('authSettings');\n\n//Get MUIlOG else create it\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//Get failedLoginTimmer else create it\nvar failedLoginTimmer = global.get('failedLoginTimmer')||{};\n\n//check that userName is in authUsers\nif (failedLoginTimmer.hasOwnProperty(socketip) ) {\n delete failedLoginTimmer[socketip];\n //failedLoginTimmer[socketip]['failedattempts'] = 1;\n}\nglobal.set('failedLoginTimmer', failedLoginTimmer);\n\nvar newLineInLog = 'Relative URL: /ui/#!/1 | ' + humanTimestamp + ` | IP - ` + socketip + ` | User: ` + userName + ` Loged-In | socket - ` + socketid;\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\n\nglobal.set('muiLog', muiLog);\n\n\nvar email = authUsers[userName].email;\nvar role = authUsers[userName].role;\nvar firstname = authUsers[userName].firstname;\nvar lastname = authUsers[userName].lastname;\nvar info = authUsers[userName].info;\n\n\n//add user as loggedin to AuthLoginCredentials\nAuthLoginCredentials[socketid]['email'] = email;\nAuthLoginCredentials[socketid]['role'] = role;\nAuthLoginCredentials[socketid]['firstname'] = firstname;\nAuthLoginCredentials[socketid]['lastname'] = lastname;\nAuthLoginCredentials[socketid]['info'] = info;\nAuthLoginCredentials[socketid]['loggedin'] = true;\n\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nAuthLoginCredentials = global.get('AuthLoginCredentials');\nmsg.AuthLoginCredentials = AuthLoginCredentials;\n\n//get ourl (original url before being sent to login page)\n//msg.ourl = AuthLoginCredentials[socketid].ourl\nreturn msg;\n\n\n\n\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 630, "y": 960, "wires": [ [ "0458c6c5015df043" ] ] }, { "id": "43a5c94ad3f1ea9c", "type": "trigger", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "op1": "", "op2": "", "op1type": "nul", "op2type": "payl", "duration": "1", "extend": true, "overrideDelay": true, "units": "s", "reset": "", "bytopic": "topic", "topic": "topic", "outputs": 1, "x": 280, "y": 800, "wires": [ [ "b00bc43078b1a729" ] ] }, { "id": "8023edab36b475cd", "type": "ui_button", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "I forgot my Username or Password", "group": "f5f7cada415a15e8", "order": 3, "width": "0", "height": "0", "passthru": false, "label": "I forgot my Username or Password", "tooltip": "", "color": "#0094CE", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 200, "y": 1040, "wires": [ [ "28d681da068bbf0b" ] ] }, { "id": "0b2d248d89b64672", "type": "ui_button", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Create a new account", "group": "f5f7cada415a15e8", "order": 1, "width": 0, "height": 0, "passthru": false, "label": "Create a new account", "tooltip": "", "color": "#0094CE", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 160, "y": 1000, "wires": [ [ "7716ec922062257a" ] ] }, { "id": "b7c718c415f19f7b", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 1290, "y": 880, "wires": [ [] ] }, { "id": "e013ceb5449a44f5", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Send User to AccountRecovery", "func": "msg.timeout = 2;\nmsg.topic = ``;\nmsg.url = '/ui/#!/3?socketid='+msg.socketid;\nmsg.payload = 'AccountRecoveryAccountRecovery';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1050, "y": 920, "wires": [ [ "51684d49566056b7" ] ] }, { "id": "998658cc1779c37f", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Unless replaceing Home Tab @ numeric index 0. Place all new Tabs below Account Tab with a numeric index of 6 or greater", "info": "", "x": 450, "y": 200, "wires": [] }, { "id": "38e86c01a34d549d", "type": "comment", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Login Tab 1", "info": "", "x": 110, "y": 480, "wires": [] }, { "id": "3d5bd741d664a5d2", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 830, "y": 920, "wires": [ [ "e013ceb5449a44f5" ] ] }, { "id": "51684d49566056b7", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 920, "wires": [] }, { "id": "8b6f192d7fa7c8e1", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 1280, "y": 760, "wires": [] }, { "id": "898945eda220874c", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Login msg & set timeout ", "func": "msg.timeout = msg.failedattempts;\nmsg.topic = '';\nmsg.payload = 'Logging In';\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1070, "y": 760, "wires": [ [ "8b6f192d7fa7c8e1" ] ] }, { "id": "d5f9e906cad8072d", "type": "ui_text", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "group": "1deed69fcda2c602", "order": 0, "width": "6", "height": "5", "name": "Automation", "label": "", "format": "

This is the Automation page

Only users that have logged in can access this page by the tab on the left of this site or directly with the URL http(s)://your-ip-address-or-domain/ui/#!/6 If a user tires to access this page or any page you have secured and they have not logged in they will be redirected to the login page.

", "layout": "col-center", "x": 130, "y": 3480, "wires": [] }, { "id": "2ac2062c48c17b5e", "type": "comment", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "Automation Tab 6", "info": "", "x": 120, "y": 3440, "wires": [] }, { "id": "91388ede8f6ae3d1", "type": "ui_ui_control", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "", "events": "change", "x": 120, "y": 3520, "wires": [ [ "0be44e8787367d0f" ] ] }, { "id": "0be44e8787367d0f", "type": "change", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 270, "y": 3520, "wires": [ [ "3e656dd98e982e1a" ] ] }, { "id": "3e656dd98e982e1a", "type": "switch", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "Change tab #", "property": "tab", "propertyType": "msg", "rules": [ { "t": "eq", "v": "6", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 440, "y": 3520, "wires": [ [ "e1fd9852384837a4" ] ] }, { "id": "7228c5e32fd6d0dd", "type": "comment", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": " ▼Tab # here▼", "info": "", "x": 440, "y": 3480, "wires": [] }, { "id": "cc0fb0628467acde", "type": "function", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "MUI LOG [connect]", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst humanTimestamp = msg.humanTimestamp;\nconst error = msg.error;\nconst tab = msg.tab.toString();\nconst newLineInLog = 'Relative URL: /ui/#!/' + tab +' | ' + humanTimestamp + ` | IP - ` + socketip + ` | ` + error + ` | socket - ` + socketid;\n\n\n//Get muiLog else create it\nvar muiLog = global.get('muiLog')||[];\n\n\n//clean up muiLog so it does not overflow.\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > 1000\nif (muiLogLength > 1000)\n{ \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\n\n\nglobal.set('muiLog', muiLog);\n\nmuiLog = global.get('muiLog');\n\nmsg.muiLog = muiLog;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 550, "y": 3560, "wires": [ [ "7cb5f75829fd1b30" ] ] }, { "id": "56c2c41b35e9240a", "type": "comment", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "User Passed checks Do stuff", "info": "", "x": 180, "y": 3600, "wires": [] }, { "id": "7cb5f75829fd1b30", "type": "function", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\nconst tab = msg.tab.toString();\nconst pageURL = '/ui/#!/' + tab;\n\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//set AuthLoginCredentials to users accessing this page\nif (!AuthLoginCredentials[socketid])\n{\n AuthLoginCredentials[socketid] = {};\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nelse\n{\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nAuthLoginCredentials = global.get('AuthLoginCredentials');\nmsg.AuthLoginCredentials = AuthLoginCredentials;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 810, "y": 3560, "wires": [ [ "55d11b9f94f4add4" ] ] }, { "id": "55d11b9f94f4add4", "type": "ui_toast", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1060, "y": 3560, "wires": [] }, { "id": "e1fd9852384837a4", "type": "change", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 630, "y": 3520, "wires": [ [ "a026144815c1fb59" ] ] }, { "id": "a026144815c1fb59", "type": "moment", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 840, "y": 3520, "wires": [ [ "c1f20c1e7f6384e5" ] ] }, { "id": "0458c6c5015df043", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\nvar destURL = '/ui/#!/0?socketid='+socketid;\n\n//Get AuthLoginCredentials\nconst AuthLoginCredentials = global.get('AuthLoginCredentials');\n//check that fromURL is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('fromURL')) {\n //destURL = fromURL+'?socketid='+socketid;\n destURL = AuthLoginCredentials[socketid].fromURL + '?socketid='+socketid;\n }\n}\n\nmsg.timeout = 2;\nmsg.topic = ``;\n\nmsg.url = destURL;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 960, "wires": [ [ "f77ade98a516b50f" ] ] }, { "id": "f77ade98a516b50f", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 960, "wires": [] }, { "id": "c1f20c1e7f6384e5", "type": "function", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "Is user logged in?", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\n//Get AuthLoginCredentials else create it\nconst AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\nvar isuerloggedin = false;\nvar error = 'User not logged in';\n\n\n//check that loggedin is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].loggedin === true) {\n isuerloggedin = true;\n //get user information from AuthLoginCredentials\n var ip = AuthLoginCredentials[socketid].ip;\n var userName = AuthLoginCredentials[socketid].userName;\n var email = AuthLoginCredentials[socketid].email;\n var role = AuthLoginCredentials[socketid].role;\n var firstname = AuthLoginCredentials[socketid].firstname;\n var lastname = AuthLoginCredentials[socketid].lastname;\n var info = AuthLoginCredentials[socketid].info;\n //if the ip that the user logged in with\n //that is tied to the socketid of that login\n //is diffrent then the ip used to get to this page\n //kick the record and send user back to login page\n if(ip !== socketip) {\n delete AuthLoginCredentials[socketid];\n error = 'socketip: '+socketip+' !== to Login ip: '+ip;\n msg.error = error;\n isuerloggedin = false;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n else {\n msg.error = false;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n }\n else {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n}\nelse {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1050, "y": 3520, "wires": [ [ "f7ec73f6d887b66c" ] ] }, { "id": "f7ec73f6d887b66c", "type": "switch", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "1[not logged in] 2[logged in]", "property": "error", "propertyType": "msg", "rules": [ { "t": "istype", "v": "string", "vt": "string" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 180, "y": 3560, "wires": [ [ "cc0fb0628467acde" ], [ "9cd18365033fde3a" ] ] }, { "id": "7716ec922062257a", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to Create new account page\nmsg.url = '/ui/#!/2?socketid='+socketid;\n\nmsg.payload = 'New AccountNew Account';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 590, "y": 1000, "wires": [ [ "8b32e6111c4676eb" ] ] }, { "id": "8b32e6111c4676eb", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1000, "wires": [] }, { "id": "28d681da068bbf0b", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to Account Recovery page\nmsg.url = '/ui/#!/3?socketid='+socketid;\n\nmsg.payload = 'Account RecoveryAccount Recovery';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 590, "y": 1040, "wires": [ [ "fff742d73bd5bd68" ] ] }, { "id": "fff742d73bd5bd68", "type": "ui_toast", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1040, "wires": [] }, { "id": "ef342147fce699d8", "type": "comment", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "New Account Tab 2", "info": "", "x": 130, "y": 1140, "wires": [] }, { "id": "3cf05340cf7a22cd", "type": "ui_form", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "New Account", "label": "", "group": "62b44eba9c39b679", "order": 1, "width": 0, "height": 0, "options": [ { "label": "Username", "value": "userName", "type": "text", "required": true, "rows": null }, { "label": "Password", "value": "userPassword", "type": "password", "required": true, "rows": null }, { "label": "Confirm Password", "value": "confirmPassword", "type": "password", "required": true, "rows": null }, { "label": "email", "value": "userEmail", "type": "email", "required": true, "rows": null }, { "label": "First Name", "value": "firstName", "type": "text", "required": false, "rows": null }, { "label": "Last Name", "value": "lastName", "type": "text", "required": false, "rows": null }, { "label": "Department, Job role or Title", "value": "info", "type": "text", "required": false, "rows": null } ], "formValue": { "userName": "", "userPassword": "", "confirmPassword": "", "userEmail": "", "firstName": "", "lastName": "", "info": "" }, "payload": "", "submit": "submit", "cancel": "", "topic": "topic", "topicType": "msg", "splitLayout": "", "x": 130, "y": 1180, "wires": [ [ "a9d382f1e9a90359" ] ] }, { "id": "a9d382f1e9a90359", "type": "function", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "Submition Checks", "func": "const userSubmition = msg.payload;\nconst socketid = msg.socketid;\nconst authUsers = global.get('authUsers');\nconst userName = msg.payload.userName;\nconst userPassword = msg.payload.userPassword;\nconst confirmPassword = msg.payload.confirmPassword;\nconst userEmail = msg.payload.userEmail;\nconst firstName = msg.payload.firstName;\nconst lastName = msg.payload.lastName;\nconst info = msg.payload.info;\nconst authSettings = global.get('authSettings');\n\n// Password Regex pattern checker\nconst containsNchar = new RegExp('(?=.{'+authSettings.passReq.mustContainMinCharOf+',})');\nconst containsOneUppercase = new RegExp('(?=.*[A-Z])');\nconst containsOneLowercase = new RegExp('(?=.*[a-z])');\nconst containsOneNumber = new RegExp('(?=.*[0-9])');\nconst containsOneSpecialChar = new RegExp('(?=.*[@$!%*?&])');\n\nvar authUsersEmailsArray = [];\n\n\n//creat an arry of allready used emails\n//get all keys(usernames) from the authUsers object first\nconst authUsersKeys = Object.keys(authUsers);\nauthUsersKeys.forEach(function(eachUserName) {\n let eachEmail = authUsers[eachUserName].email;\n authUsersEmailsArray.push(eachEmail);\n});\n\n\n//check that userName is not allready taken by another user in authUsers\nif (authUsers.hasOwnProperty(userName) ) {\n msg.error = true;\n msg.topic = 'Username already in use';\n msg.payload = 'Please Choose another Username';\n msg.userSubmition = userSubmition;\n return msg;\n}\nif (userPassword !== confirmPassword) {\n msg.error = true;\n msg.topic = 'Passwords do not match';\n msg.payload = 'Please enter matching Passwords';\n msg.userSubmition = userSubmition;\n return msg;\n}\nif (!containsNchar.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password too short';\n msg.payload = 'Must be longer than '+ authSettings.passReq.mustContainMinCharOf.toString() +' characters';\n return msg;\n}\nif (authSettings.passReq.mustContainMinOneUppercase) {\n if (!containsOneUppercase.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks uppercase character';\n msg.payload = 'Must contain at least one upper uppercase character. Like ABCDEFG';\n return msg;\n }\n \n}\nif (authSettings.passReq.mustContainMinOneLowercase) {\n if (!containsOneLowercase.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks lowercase character';\n msg.payload = 'Must contain at least one lowercase character. Like abcdefg';\n return msg;\n }\n}\nif (authSettings.passReq.mustContainMinOneNumber) {\n if (!containsOneNumber.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks a number';\n msg.payload = 'Must contain at least one number. Like 1234567';\n return msg;\n }\n}\nif (authSettings.passReq.mustContainMinOneSpecialChar) {\n if (!containsOneSpecialChar.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks a special character';\n msg.payload = 'Must contain at least one of these special characters. @$!%*?&';\n return msg;\n }\n}\nif (authUsersEmailsArray.includes(userEmail)) {\n msg.error = true;\n msg.topic = 'Email already in use';\n msg.payload = 'Please recover account';\n msg.userSubmition = userSubmition;\n return msg;\n}\nif (true) {\n msg.timeout = 3;\n msg.error = false;\n msg.topic = 'New Account Request';\n msg.payload = 'Submitted';\n msg.userSubmition = userSubmition;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 310, "y": 1180, "wires": [ [ "7a8a0c157c244ef0" ] ] }, { "id": "7a8a0c157c244ef0", "type": "switch", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 470, "y": 1180, "wires": [ [ "0b5806ddfdef26e0" ], [ "fe57b5e9f6f261fc" ] ] }, { "id": "0b5806ddfdef26e0", "type": "ui_toast", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 650, "y": 1180, "wires": [ [ "33735e80aa3a4ba9" ] ] }, { "id": "33735e80aa3a4ba9", "type": "switch", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "property": "topic", "propertyType": "msg", "rules": [ { "t": "cont", "v": "Email", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 790, "y": 1180, "wires": [ [ "fb6ee227bd5d3d60" ] ] }, { "id": "6e6425b0963d55ac", "type": "ui_toast", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1180, "wires": [] }, { "id": "fb6ee227bd5d3d60", "type": "function", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to Account Recovery page\nmsg.url = '/ui/#!/3?socketid='+socketid;\n\nmsg.payload = 'Account RecoveryAccount Recovery';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1180, "wires": [ [ "6e6425b0963d55ac" ] ] }, { "id": "9cd18365033fde3a", "type": "debug", "z": "665e920cca795df7", "g": "9999f11f35f2d72d", "name": "USER SUCCESS | logged in | trigger stuff on the page etc", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 270, "y": 3640, "wires": [] }, { "id": "b0c9bb5058b48481", "type": "function", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "newUesrRequests & MUI LOG", "func": "const socketid = msg.socketid;\nconst userSubmition = msg.userSubmition;\nconst authSettings = global.get('authSettings');\nconst humanTimestamp = msg.humanTimestamp;\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n \n //Get newUesrRequests else create it\n var newUesrRequests = global.get('newUesrRequests')||{};\n \n //clean up newUesrRequests so it does not overflow.\n //Set max length of newUesrRequests object, \n var newUesrRequestsMaxLength = authSettings.newUesrs.newUesrRequestsMaxPending;\n //get keys newUesrRequests object \n var newUesrRequestsKeys = Object.keys(newUesrRequests);\n //get length of newUesrRequests object \n var newUesrRequestsLength = newUesrRequestsKeys.length;\n //remove 2 items from newUesrRequests if > newUesrRequestsMaxLength\n if (newUesrRequestsLength > newUesrRequestsMaxLength)\n { \n delete newUesrRequests[newUesrRequestsKeys[0]];\n delete newUesrRequests[newUesrRequestsKeys[1]];\n }\n \n //set newUesrRequests to values submitted in form\n if (!newUesrRequests[userSubmition.userName])\n {\n newUesrRequests[userSubmition.userName] = {};\n newUesrRequests[userSubmition.userName]['userPassword'] = userSubmition.userPassword;\n newUesrRequests[userSubmition.userName]['userEmail'] = userSubmition.userEmail;\n newUesrRequests[userSubmition.userName]['userRole'] = 'user';\n newUesrRequests[userSubmition.userName]['firstName'] = userSubmition.firstName;\n newUesrRequests[userSubmition.userName]['lastName'] = userSubmition.lastName;\n newUesrRequests[userSubmition.userName]['info'] = userSubmition.info;\n newUesrRequests[userSubmition.userName]['ip'] = socketip;\n }\n else\n {\n newUesrRequests[userSubmition.userName]['userPassword'] = userSubmition.userPassword;\n newUesrRequests[userSubmition.userName]['userEmail'] = userSubmition.userEmail.toLowerCase();\n newUesrRequests[userSubmition.userName]['userRole'] = 'user';\n newUesrRequests[userSubmition.userName]['firstName'] = userSubmition.firstName;\n newUesrRequests[userSubmition.userName]['lastName'] = userSubmition.lastName;\n newUesrRequests[userSubmition.userName]['info'] = userSubmition.info;\n newUesrRequests[userSubmition.userName]['ip'] = socketip;\n }\n global.set('newUesrRequests', newUesrRequests);\n newLineInLog = 'Relative URL: /ui/#!/2 | '+ humanTimestamp + ` | IP - ` + socketip + ` | ` + `Newuser Request Submitted | socket - ` + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n msg.topic = 'Request';\n msg.payload = 'Submitted';\n msg.userSubmition = userSubmition;\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 390, "y": 1260, "wires": [ [ "22b415c032b32065" ] ] }, { "id": "44d397d0b43d7904", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "action": "encrypt", "field": "userSubmition.userPassword", "hash": "", "rounds": "4", "x": 130, "y": 1260, "wires": [ [ "b0c9bb5058b48481" ] ] }, { "id": "fe57b5e9f6f261fc", "type": "change", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 150, "y": 1220, "wires": [ [ "22e2d6932a7bf75c" ] ] }, { "id": "22e2d6932a7bf75c", "type": "moment", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 420, "y": 1220, "wires": [ [ "44d397d0b43d7904" ] ] }, { "id": "22b415c032b32065", "type": "switch", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 630, "y": 1240, "wires": [ [ "e38ed715d82bd075" ], [ "a0fc0e1426046106" ] ] }, { "id": "e38ed715d82bd075", "type": "function", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1220, "wires": [ [ "4533746bf9bd6c56" ] ] }, { "id": "4533746bf9bd6c56", "type": "ui_toast", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1220, "wires": [] }, { "id": "a0fc0e1426046106", "type": "function", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to homepage\nmsg.url = '/ui/#!/0?socketid='+socketid;\n\nmsg.payload = 'Request SubmittedRequest Submitted';\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1260, "wires": [ [ "ad05bbb8b3ebd66f" ] ] }, { "id": "ad05bbb8b3ebd66f", "type": "ui_toast", "z": "665e920cca795df7", "g": "2728795157ecb5a1", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1260, "wires": [] }, { "id": "f07163f79c764fbe", "type": "comment", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "Things todo when node-red starts", "info": "", "x": 170, "y": 3740, "wires": [] }, { "id": "2fb231241c6aaa54", "type": "comment", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "import auth file to flow.auth if it exzists, if not then create a new one.", "info": "", "x": 320, "y": 3780, "wires": [] }, { "id": "0e4dc2b9bbd0550c", "type": "file in", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "filename": "./data/auth/authUsers.dat", "format": "utf8", "chunk": false, "sendError": false, "encoding": "none", "allProps": false, "x": 430, "y": 3820, "wires": [ [ "3fca8a532ffa3ea5" ] ] }, { "id": "ab237985603dccdb", "type": "inject", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payloadType": "date", "x": 170, "y": 3820, "wires": [ [ "0e4dc2b9bbd0550c" ] ] }, { "id": "ec27ef518271709d", "type": "debug", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1330, "y": 3820, "wires": [] }, { "id": "3fca8a532ffa3ea5", "type": "json", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "property": "payload", "action": "obj", "pretty": false, "x": 610, "y": 3820, "wires": [ [ "3cb4d716e31f4b65" ] ] }, { "id": "63aebc9bd72c5e14", "type": "change", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "rules": [ { "t": "set", "p": "authUsers", "pt": "global", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1160, "y": 3820, "wires": [ [ "ec27ef518271709d" ] ] }, { "id": "88a55a5c51ebfa91", "type": "catch", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "scope": [ "0e4dc2b9bbd0550c" ], "uncaught": false, "x": 290, "y": 3860, "wires": [ [ "4b0b6adcd85edcf1" ] ] }, { "id": "3cb4d716e31f4b65", "type": "switch", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "msg.payload.admin has key password", "property": "payload.admin", "propertyType": "msg", "rules": [ { "t": "hask", "v": "password", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 850, "y": 3820, "wires": [ [ "63aebc9bd72c5e14" ], [ "4b0b6adcd85edcf1" ] ] }, { "id": "d2d121d0754878ee", "type": "comment", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "import authsettings file to flow.authsettings if it exzists, if not then create a new one.", "info": "", "x": 370, "y": 3900, "wires": [] }, { "id": "394e2b5c929c0b83", "type": "file in", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "filename": "./data/auth/authSettings.dat", "format": "utf8", "chunk": false, "sendError": false, "encoding": "none", "allProps": false, "x": 420, "y": 3940, "wires": [ [ "14e682d681c51d30" ] ] }, { "id": "ae648d9f17fe7f97", "type": "debug", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1330, "y": 3940, "wires": [] }, { "id": "14e682d681c51d30", "type": "json", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "property": "payload", "action": "obj", "pretty": false, "x": 610, "y": 3940, "wires": [ [ "69cea5dd7286314b" ] ] }, { "id": "c2b4637397048e51", "type": "change", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "rules": [ { "t": "set", "p": "authSettings", "pt": "global", "to": "payload", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1160, "y": 3940, "wires": [ [ "ae648d9f17fe7f97" ] ] }, { "id": "cacf2070b1f7fafd", "type": "catch", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "scope": [ "394e2b5c929c0b83" ], "uncaught": false, "x": 290, "y": 3980, "wires": [ [ "90471faa7e307334" ] ] }, { "id": "69cea5dd7286314b", "type": "switch", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "msg.payload.muiLogin has key maxSocketips", "property": "payload.muiLogin", "propertyType": "msg", "rules": [ { "t": "hask", "v": "maxSocketips", "vt": "str" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 850, "y": 3940, "wires": [ [ "c2b4637397048e51" ], [ "90471faa7e307334" ] ] }, { "id": "cd7fb8afa0f15a67", "type": "inject", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": true, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 170, "y": 3940, "wires": [ [ "394e2b5c929c0b83" ] ] }, { "id": "4b0b6adcd85edcf1", "type": "change", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "rules": [ { "t": "set", "p": "password", "pt": "msg", "to": "password", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 450, "y": 3860, "wires": [ [ "b22dde67c3b464ac" ] ] }, { "id": "b22dde67c3b464ac", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "action": "encrypt", "field": "password", "hash": "", "rounds": "4", "x": 630, "y": 3860, "wires": [ [ "dede0f69e5d35dd2" ] ] }, { "id": "2849dad2b983b2a9", "type": "debug", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1330, "y": 3980, "wires": [] }, { "id": "807f50c238575f6f", "type": "file", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "filename": "./data/auth/authSettings.dat", "appendNewline": false, "createDir": true, "overwriteFile": "true", "encoding": "none", "x": 1140, "y": 3980, "wires": [ [ "2849dad2b983b2a9" ] ] }, { "id": "90471faa7e307334", "type": "function", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "settings object", "func": "//function randomString(length, chars) {\n// var result = '';\n// for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];\n// return result;\n//}\n//create a random 32 char string for encrypt/decrypt of user passwords\n//var rString = randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\n\n\nmsg.payload = {\n muiLogin : {\n maxSocketips : 1000\n },\n muiLog : {\n maxmuiLogLength : 250\n },\n newUesrs : {\n newUesrRequestsMaxPending : 1000\n },\n passReq : {\n mustContainMinCharOf : 8,\n mustContainMinOneUppercase : true,\n mustContainMinOneLowercase : true,\n mustContainMinOneNumber : true,\n mustContainMinOneSpecialChar : false\n },\n emailSupportEnabled : false\n \n //ranString : rString\n}\n\nreturn msg;\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 460, "y": 3980, "wires": [ [ "2d0575b580beb6e7", "69cea5dd7286314b" ] ] }, { "id": "2d0575b580beb6e7", "type": "json", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "property": "payload", "action": "str", "pretty": false, "x": 610, "y": 3980, "wires": [ [ "807f50c238575f6f" ] ] }, { "id": "bb685987ecd19262", "type": "debug", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1330, "y": 3860, "wires": [] }, { "id": "b7b0ba0b444fdcdd", "type": "file", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "filename": "./data/auth/authUsers.dat", "appendNewline": false, "createDir": true, "overwriteFile": "true", "encoding": "none", "x": 1150, "y": 3860, "wires": [ [ "bb685987ecd19262" ] ] }, { "id": "dede0f69e5d35dd2", "type": "function", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "authUsers object", "func": "var msg_password = msg.password;\nmsg.payload = {\n admin : {\n password : msg_password,\n email : 'admin@admin.com',\n role : 'admin',\n firstname : 'john',\n lastname : 'doe',\n info : 'accounting department'\n }\n}\n\n\n\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 810, "y": 3860, "wires": [ [ "2a1f1724aa93eef6", "3cb4d716e31f4b65" ] ] }, { "id": "2a1f1724aa93eef6", "type": "json", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "property": "payload", "action": "str", "pretty": false, "x": 970, "y": 3860, "wires": [ [ "b7b0ba0b444fdcdd" ] ] }, { "id": "ac4a6a0d03e4d11b", "type": "ui_text", "z": "665e920cca795df7", "g": "e47b43ae86e94cd7", "group": "4edfae8b.b8925", "order": 2, "width": 0, "height": 0, "name": "", "label": "", "format": "

This is the Homepage

Any one that has the URL http(s)://your-ip-address-or-domain/ui/ can access this page without a login.

", "layout": "col-center", "x": 90, "y": 380, "wires": [] }, { "id": "344df62c29ce0de1", "type": "comment", "z": "665e920cca795df7", "g": "e47b43ae86e94cd7", "name": "Home Tab 0", "info": "", "x": 110, "y": 340, "wires": [] }, { "id": "349930bac63f4f32", "type": "inject", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 160, "y": 3980, "wires": [ [ "90471faa7e307334" ] ] }, { "id": "329ba949f0a48147", "type": "inject", "z": "665e920cca795df7", "g": "a89307a8db096479", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 160, "y": 3860, "wires": [ [ "4b0b6adcd85edcf1" ] ] }, { "id": "3e96c9ad7ac7e040", "type": "debug", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "debug", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 370, "y": 140, "wires": [] }, { "id": "5d65db1a17172399", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Please setup a email node and attach it to the link in, and or replacing the debug node if you enable email support in the admin console of the dashboard page", "info": "", "x": 560, "y": 100, "wires": [] }, { "id": "1618be83e8776c89", "type": "link in", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "email link in", "links": [ "e1ef84ae04062dd2", "c58a466d79445350", "70129261bc9dbe85" ], "x": 275, "y": 140, "wires": [ [ "3e96c9ad7ac7e040" ] ] }, { "id": "4346b596f8a20f3a", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Email Node Goes Here", "info": "", "x": 140, "y": 140, "wires": [] }, { "id": "8196d13687d8d4fe", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Email", "info": "", "x": 90, "y": 60, "wires": [] }, { "id": "2b87940d2c61db6d", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Leave property [To] field blank. The email address is provided by the users account!", "info": "", "x": 450, "y": 60, "wires": [] }, { "id": "e9b66dece7c29b6b", "type": "comment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Account Tab 4", "info": "", "x": 110, "y": 1620, "wires": [] }, { "id": "5b6330732e248865", "type": "ui_form", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Update Password", "label": "Update Your Password", "group": "205ac72e296cb65f", "order": 3, "width": 0, "height": 0, "options": [ { "label": "Password", "value": "userPassword", "type": "password", "required": true, "rows": null }, { "label": "Confirm Password", "value": "confirmPassword", "type": "password", "required": true, "rows": null } ], "formValue": { "userPassword": "", "confirmPassword": "" }, "payload": "", "submit": "Update", "cancel": "", "topic": "topic", "topicType": "msg", "splitLayout": "", "x": 190, "y": 1860, "wires": [ [ "89fadb8ea4d690ae" ] ] }, { "id": "5c6ff58051946f04", "type": "ui_ui_control", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "events": "change", "x": 120, "y": 1660, "wires": [ [ "d94b4768ba3fecee" ] ] }, { "id": "d94b4768ba3fecee", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 270, "y": 1660, "wires": [ [ "afb7575db0306542" ] ] }, { "id": "afb7575db0306542", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Change tab #", "property": "tab", "propertyType": "msg", "rules": [ { "t": "eq", "v": "4", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 440, "y": 1660, "wires": [ [ "dfafdd31c9594ae6" ] ] }, { "id": "07063b2f20a14e00", "type": "comment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "<----- Put the Page Tab number in here", "info": "", "x": 690, "y": 1660, "wires": [] }, { "id": "bcf900f54ec95e41", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "MUI LOG [connect]", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst humanTimestamp = msg.humanTimestamp;\nconst error = msg.error;\nconst tab = msg.tab.toString();\nconst newLineInLog = 'Relative URL: /ui/#!/' + tab +' | ' + humanTimestamp + ` | IP - ` + socketip + ` | ` + error + ` | socket - ` + socketid;\n\n\n//Get muiLog else create it\nvar muiLog = global.get('muiLog')||[];\n\n\n\n\n//clean up muiLog so it does not overflow.\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > 1000\nif (muiLogLength > 1000)\n{ \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\n\n\nglobal.set('muiLog', muiLog);\n\nmuiLog = global.get('muiLog');\n\nmsg.muiLog = muiLog;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 1700, "wires": [ [ "b2cf83332f28fb81" ] ] }, { "id": "b2cf83332f28fb81", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\nconst tab = msg.tab.toString();\nconst pageURL = '/ui/#!/' + tab;\n\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//set AuthLoginCredentials to users accessing this page\nif (!AuthLoginCredentials[socketid])\n{\n AuthLoginCredentials[socketid] = {};\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nelse\n{\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nAuthLoginCredentials = global.get('AuthLoginCredentials');\nmsg.AuthLoginCredentials = AuthLoginCredentials;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 910, "y": 1700, "wires": [ [ "6532082cb07fee9b" ] ] }, { "id": "6532082cb07fee9b", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1180, "y": 1700, "wires": [] }, { "id": "dfafdd31c9594ae6", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 950, "y": 1660, "wires": [ [ "484779d81c6fa129" ] ] }, { "id": "484779d81c6fa129", "type": "moment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 1160, "y": 1660, "wires": [ [ "a8f8071f58de9b68" ] ] }, { "id": "a8f8071f58de9b68", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Is user logged in?", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\n//Get AuthLoginCredentials else create it\nconst AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\nvar isuerloggedin = false;\nvar error = 'User not logged in';\n\n\n//check that loggedin is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].loggedin === true) {\n isuerloggedin = true;\n //get user information from AuthLoginCredentials\n var ip = AuthLoginCredentials[socketid].ip;\n var userName = AuthLoginCredentials[socketid].userName;\n var email = AuthLoginCredentials[socketid].email;\n var role = AuthLoginCredentials[socketid].role;\n var firstname = AuthLoginCredentials[socketid].firstname;\n var lastname = AuthLoginCredentials[socketid].lastname;\n var info = AuthLoginCredentials[socketid].info;\n //if the ip that the user logged in with\n //that is tied to the socketid of that login\n //is diffrent then the ip used to get to this page\n //kick the record and send user back to login page\n if(ip !== socketip) {\n delete AuthLoginCredentials[socketid];\n error = 'socketip: '+socketip+' !== to Login ip: '+ip;\n msg.error = error;\n isuerloggedin = false;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n else {\n msg.error = false;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n }\n else {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n}\nelse {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 150, "y": 1700, "wires": [ [ "50d746116becb07d" ] ] }, { "id": "50d746116becb07d", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "1[not logged in] 2[logged in]", "property": "error", "propertyType": "msg", "rules": [ { "t": "istype", "v": "string", "vt": "string" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 380, "y": 1700, "wires": [ [ "bcf900f54ec95e41" ], [] ] }, { "id": "e3b1191aa66c6cd2", "type": "ui_button", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "group": "205ac72e296cb65f", "order": 1, "width": 0, "height": 0, "passthru": false, "label": "Delete Your Account", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 160, "y": 1780, "wires": [ [ "a44fc16f56918a19" ] ] }, { "id": "35a5e0abbebd893c", "type": "ui_text", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "group": "205ac72e296cb65f", "order": 2, "width": 0, "height": 0, "name": "blank", "label": "", "format": "", "layout": "col-center", "x": 75, "y": 1860, "wires": [], "l": false }, { "id": "a44fc16f56918a19", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "Warning!", "tot": "str" }, { "t": "set", "p": "payload", "pt": "msg", "to": "You are about to remove all your account information and delete yourself from the system. Are you sure you want to continue?", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 360, "y": 1780, "wires": [ [ "84584d38a55c661e" ] ] }, { "id": "84584d38a55c661e", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "CANCEL", "raw": false, "topic": "", "name": "", "x": 530, "y": 1780, "wires": [ [ "06a4283747f99ffd" ] ] }, { "id": "06a4283747f99ffd", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "CANCEL", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 670, "y": 1780, "wires": [ [], [ "9068983f98cf3c94" ] ] }, { "id": "c88dcd345011bead", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Delete Account & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nvar authUsers = global.get('authUsers');\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n \n //Get get the current userName that clicked the button\n const userName = AuthLoginCredentials[socketid].userName;\n \n //Delete the user from system\n delete authUsers[userName];\n global.set('authUsers', authUsers);\n \n newLineInLog = 'Relative URL: /ui/#!/4 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Deleted themselves from the system | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 600, "y": 1820, "wires": [ [ "5f74b446d3e223d8" ] ] }, { "id": "9068983f98cf3c94", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 150, "y": 1820, "wires": [ [ "13a6ec31df3c2d1f" ] ] }, { "id": "13a6ec31df3c2d1f", "type": "moment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 360, "y": 1820, "wires": [ [ "c88dcd345011bead" ] ] }, { "id": "beac5465362cd688", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1780, "wires": [ [ "d9616b38a2322243" ] ] }, { "id": "64e749ec85d66e5c", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to homepage by /ui/ so they get a new socketid. this way the socketid they had tied tp AuthLoginCredentials will be deleted\nmsg.url = '/ui/';\n\nmsg.payload = 'Account DeletedAccount Deleted';\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1820, "wires": [ [ "a7bb3a7ffe3c3873" ] ] }, { "id": "5f74b446d3e223d8", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 810, "y": 1800, "wires": [ [ "beac5465362cd688" ], [ "64e749ec85d66e5c" ] ] }, { "id": "d9616b38a2322243", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1780, "wires": [] }, { "id": "a7bb3a7ffe3c3873", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1820, "wires": [] }, { "id": "89fadb8ea4d690ae", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Submition Checks", "func": "const userSubmition = msg.payload;\nconst socketid = msg.socketid;\nconst authUsers = global.get('authUsers');\nconst userPassword = msg.payload.userPassword;\nconst confirmPassword = msg.payload.confirmPassword;\nconst authSettings = global.get('authSettings');\n\n// Password Regex pattern checker\nconst containsNchar = new RegExp('(?=.{'+authSettings.passReq.mustContainMinCharOf+',})');\nconst containsOneUppercase = new RegExp('(?=.*[A-Z])');\nconst containsOneLowercase = new RegExp('(?=.*[a-z])');\nconst containsOneNumber = new RegExp('(?=.*[0-9])');\nconst containsOneSpecialChar = new RegExp('(?=.*[@$!%*?&])');\n\nif (userPassword !== confirmPassword) {\n msg.error = true;\n msg.topic = 'Passwords do not match';\n msg.payload = 'Please enter matching Passwords';\n return msg;\n}\nif (!containsNchar.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password too short';\n msg.payload = 'Must be longer than '+ authSettings.passReq.mustContainMinCharOf.toString() +' characters';\n return msg;\n}\nif (authSettings.passReq.mustContainMinOneUppercase) {\n if (!containsOneUppercase.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks uppercase character';\n msg.payload = 'Must contain at least one upper uppercase character. Like ABCDEFG';\n return msg;\n }\n \n}\nif (authSettings.passReq.mustContainMinOneLowercase) {\n if (!containsOneLowercase.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks lowercase character';\n msg.payload = 'Must contain at least one lowercase character. Like abcdefg';\n return msg;\n }\n}\nif (authSettings.passReq.mustContainMinOneNumber) {\n if (!containsOneNumber.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks a number';\n msg.payload = 'Must contain at least one number. Like 1234567';\n return msg;\n }\n}\nif (authSettings.passReq.mustContainMinOneSpecialChar) {\n if (!containsOneSpecialChar.test(userPassword)) {\n msg.error = true;\n msg.topic = 'Password lacks a special character';\n msg.payload = 'Must contain at least one of these special characters. @$!%*?&';\n return msg;\n }\n}\nif (true) {\n\n msg.error = false;\n msg.userSubmition = userSubmition;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 1860, "wires": [ [ "ebbad3b98280a9f9" ] ] }, { "id": "9d5e12a156cbe6dd", "type": "ui_form", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Update Email", "label": "Update Your Email", "group": "205ac72e296cb65f", "order": 4, "width": 0, "height": 0, "options": [ { "label": "email", "value": "userEmail", "type": "email", "required": true, "rows": null } ], "formValue": { "userEmail": "" }, "payload": "", "submit": "Update", "cancel": "", "topic": "topic", "topicType": "msg", "splitLayout": "", "x": 140, "y": 1980, "wires": [ [ "7a59b29b4dc49c9b" ] ] }, { "id": "ebbad3b98280a9f9", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 570, "y": 1860, "wires": [ [ "e114f03c40305ca1" ], [ "3ef89204f2fc2097" ] ] }, { "id": "e114f03c40305ca1", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 750, "y": 1860, "wires": [ [] ] }, { "id": "3ef89204f2fc2097", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 150, "y": 1900, "wires": [ [ "618813b82d34c25b" ] ] }, { "id": "618813b82d34c25b", "type": "moment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 400, "y": 1900, "wires": [ [ "b364ee1da4b51cb9" ] ] }, { "id": "1269b8e25d4490f6", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Update userPassword & MUI LOG", "func": "const socketid = msg.socketid;\nconst userSubmition = msg.userSubmition;\nconst authSettings = global.get('authSettings');\nconst humanTimestamp = msg.humanTimestamp;\nvar authUsers = global.get('authUsers');\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n \n //Get get the current userName that clicked the button\n const userName = AuthLoginCredentials[socketid].userName;\n \n authUsers[userName].password = userSubmition.userPassword;\n global.set('authUsers', authUsers);\n \n newLineInLog = 'Relative URL: /ui/#!/4 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Updated thier password | socket - ' + socketid; //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 360, "y": 1940, "wires": [ [ "f3facbcda9108ee2" ] ] }, { "id": "b364ee1da4b51cb9", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "action": "encrypt", "field": "userSubmition.userPassword", "hash": "", "rounds": "4", "x": 130, "y": 1940, "wires": [ [ "1269b8e25d4490f6" ] ] }, { "id": "f3facbcda9108ee2", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 810, "y": 1920, "wires": [ [ "9659ef05309c1311" ], [ "2b1adf33cca61316" ] ] }, { "id": "9659ef05309c1311", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1900, "wires": [ [ "99ab6a24b468dad0" ] ] }, { "id": "99ab6a24b468dad0", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1900, "wires": [] }, { "id": "672b433ec11e9e17", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1940, "wires": [] }, { "id": "2b1adf33cca61316", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'Password UpdatedPassword Updated';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1940, "wires": [ [ "672b433ec11e9e17" ] ] }, { "id": "c9d27a06199c5c56", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 570, "y": 1980, "wires": [ [ "d852f2b3ab93ad39" ], [ "d1ce7ce00cfcbed3" ] ] }, { "id": "d852f2b3ab93ad39", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 750, "y": 1980, "wires": [ [] ] }, { "id": "7a59b29b4dc49c9b", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Submition Checks", "func": "const userSubmition = msg.payload;\nconst socketid = msg.socketid;\nconst authUsers = global.get('authUsers');\nconst userEmail = msg.payload.userEmail;\nconst authSettings = global.get('authSettings');\n\nvar authUsersEmailsArray = [];\n\n\n//creat an arry of allready used emails\n//get all keys(usernames) from the authUsers object first\nconst authUsersKeys = Object.keys(authUsers);\nauthUsersKeys.forEach(function(eachUserName) {\n let eachEmail = authUsers[eachUserName].email;\n authUsersEmailsArray.push(eachEmail);\n});\n\nif (authUsersEmailsArray.includes(userEmail)) {\n msg.error = true;\n msg.topic = 'Email already in use';\n msg.payload = 'Please recover account';\n msg.userSubmition = userSubmition;\n return msg;\n}\nif (true) {\n\n msg.error = false;\n msg.userSubmition = userSubmition;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 410, "y": 1980, "wires": [ [ "c9d27a06199c5c56" ] ] }, { "id": "d1ce7ce00cfcbed3", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 150, "y": 2020, "wires": [ [ "bcefeff738b1b85b" ] ] }, { "id": "bcefeff738b1b85b", "type": "moment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 400, "y": 2020, "wires": [ [ "7b814871ab916ec5" ] ] }, { "id": "7b814871ab916ec5", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Update userPassword & MUI LOG", "func": "const socketid = msg.socketid;\nconst userSubmition = msg.userSubmition;\nconst authSettings = global.get('authSettings');\nconst humanTimestamp = msg.humanTimestamp;\nvar authUsers = global.get('authUsers');\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n \n //Get get the current userName that clicked the button\n const userName = AuthLoginCredentials[socketid].userName;\n \n authUsers[userName].email = userSubmition.userEmail;\n global.set('authUsers', authUsers);\n \n newLineInLog = 'Relative URL: /ui/#!/4 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Updated thier email | socket - ' + socketid; //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n msg.topic = '';\n msg.payload = 'Login';\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 200, "y": 2060, "wires": [ [ "45a6e1b70101da3d" ] ] }, { "id": "45a6e1b70101da3d", "type": "switch", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 810, "y": 2060, "wires": [ [ "6fbe93cdb7209abc" ], [ "d47604c1f266e61b" ] ] }, { "id": "6fbe93cdb7209abc", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 2040, "wires": [ [ "c57302da4ee53cb1" ] ] }, { "id": "c57302da4ee53cb1", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2040, "wires": [] }, { "id": "02fe774de2160772", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2080, "wires": [] }, { "id": "d47604c1f266e61b", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Format Payload for notification node", "func": "const email = msg.userSubmition.userEmail;\nconst socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = `Email Updated`;\n\nmsg.payload = email;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 2080, "wires": [ [ "02fe774de2160772" ] ] }, { "id": "8b1a3ba309939d68", "type": "comment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Admin Tab 5", "info": "", "x": 110, "y": 2220, "wires": [] }, { "id": "6a96a2f61d41a5df", "type": "ui_ui_control", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "events": "change", "x": 120, "y": 2260, "wires": [ [ "b69c66a718669d38" ] ] }, { "id": "b69c66a718669d38", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "socketid", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 270, "y": 2260, "wires": [ [ "3d2597702d94810a" ] ] }, { "id": "3d2597702d94810a", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Change tab #", "property": "tab", "propertyType": "msg", "rules": [ { "t": "eq", "v": "5", "vt": "num" } ], "checkall": "true", "repair": false, "outputs": 1, "x": 440, "y": 2260, "wires": [ [ "53a667e1f0e49824" ] ] }, { "id": "be5292d5e065decf", "type": "comment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "<----- Put the Page Tab number in here", "info": "", "x": 690, "y": 2260, "wires": [] }, { "id": "b7b2d0d2443909dd", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "MUI LOG [connect]", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst humanTimestamp = msg.humanTimestamp;\nconst error = msg.error;\nconst tab = msg.tab.toString();\nconst newLineInLog = 'Relative URL: /ui/#!/' + tab +' | ' + humanTimestamp + ` | IP - ` + socketip + ` | ` + error + ` | socket - ` + socketid;\n\n//Get muiLog else create it\nvar muiLog = global.get('muiLog')||[];\n\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\nglobal.set('muiLog', muiLog);\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 2300, "wires": [ [ "b229cc1b1267098f" ] ] }, { "id": "b229cc1b1267098f", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\nconst tab = msg.tab.toString();\nconst pageURL = '/ui/#!/' + tab;\n\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//set AuthLoginCredentials to users accessing this page\nif (!AuthLoginCredentials[socketid])\n{\n AuthLoginCredentials[socketid] = {};\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nelse\n{\n AuthLoginCredentials[socketid]['fromURL'] = pageURL;\n}\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nAuthLoginCredentials = global.get('AuthLoginCredentials');\nmsg.AuthLoginCredentials = AuthLoginCredentials;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to login page\nmsg.url = '/ui/#!/1?socketid='+socketid;\n\nmsg.payload = 'LoginLogin';\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 2300, "wires": [ [ "0b56d3ca1a44a502" ] ] }, { "id": "0b56d3ca1a44a502", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2300, "wires": [] }, { "id": "53a667e1f0e49824", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1050, "y": 2260, "wires": [ [ "4cdbaca3dd65d3df" ] ] }, { "id": "4cdbaca3dd65d3df", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 1260, "y": 2260, "wires": [ [ "e16c049054b50c0f" ] ] }, { "id": "e16c049054b50c0f", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Is user logged in?", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\nvar isuerloggedin = false;\nvar error = 'User not logged in';\n\n\n//check that loggedin is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].loggedin === true) {\n isuerloggedin = true;\n //get user information from AuthLoginCredentials\n const ip = AuthLoginCredentials[socketid].ip;\n const userName = AuthLoginCredentials[socketid].userName;\n const email = AuthLoginCredentials[socketid].email;\n const role = AuthLoginCredentials[socketid].role;\n const firstname = AuthLoginCredentials[socketid].firstname;\n const lastname = AuthLoginCredentials[socketid].lastname;\n const info = AuthLoginCredentials[socketid].info;\n //if the ip that the user logged in with\n //that is tied to the socketid of that login\n //is diffrent then the ip used to get to this page\n //kick the record and send user back to login page\n if(ip !== socketip) {\n delete AuthLoginCredentials[socketid];\n error = 'User: '+userName+' socketip: '+socketip+' !== to Login ip: '+ip;\n msg.error = error;\n isuerloggedin = false;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n if (role === 'admin') {\n msg.error = false;\n return msg;\n }\n else {\n msg.error = 'User: '+userName+' Lacks Role';\n msg.isuerloggedin = false;\n return msg;\n }\n }\n else {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n }\n}\nelse {\n msg.error = error;\n msg.isuerloggedin = isuerloggedin;\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 150, "y": 2300, "wires": [ [ "c190e05ace9bd4e0" ] ] }, { "id": "c190e05ace9bd4e0", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "1[not logged in] 2[logged in]", "property": "error", "propertyType": "msg", "rules": [ { "t": "istype", "v": "string", "vt": "string" }, { "t": "else" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 380, "y": 2300, "wires": [ [ "b7b2d0d2443909dd" ], [ "09dd726244181888" ] ] }, { "id": "bff2cf80354f6274", "type": "ui_dropdown", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Current Users", "label": "", "tooltip": "", "place": "Select a User", "group": "cc7d7ea92ffb628f", "order": 2, "width": 0, "height": 0, "passthru": false, "multiple": false, "options": [], "payload": "", "topic": "topic", "topicType": "msg", "x": 520, "y": 2340, "wires": [ [ "4d686702d15821b8" ] ] }, { "id": "39df5ad5e775b340", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Current Users", "group": "cc7d7ea92ffb628f", "order": 1, "width": 0, "height": 0, "passthru": false, "label": "Current Users", "tooltip": "", "color": "black", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 1280, "y": 2340, "wires": [ [] ] }, { "id": "19295afe8d6f16cf", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 5, "width": "2", "height": "1", "passthru": false, "label": "Delete User", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 230, "y": 2540, "wires": [ [ "1f4c57c7b94c6cba" ] ] }, { "id": "cedf95caf505837e", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Create an arry of Current Users", "func": "const authUsers = global.get('authUsers')||{};\n\n//Create an arry of Current Users\nauthUsersNamesArray = Object.keys(authUsers);\n\nmsg.options = authUsersNamesArray\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 290, "y": 2340, "wires": [ [ "bff2cf80354f6274" ] ] }, { "id": "09dd726244181888", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "func": "\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 75, "y": 2340, "wires": [ [ "cedf95caf505837e", "6a682b3f32705976", "27a26fc8fcefc195" ] ], "l": false }, { "id": "4d686702d15821b8", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "admin selections", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst authUsers = global.get('authUsers')||{};\nvar currentUser = msg.payload;\n\n\n//Get admingSelections else create it\nvar admingSelections = global.get('admingSelections')||{};\n\n\n//clean up admingSelections so it does not overflow.\nvar admingSelectionsMaxLength = 1000;\n//get keys admingSelections object \nvar admingSelectionsKeys = Object.keys(admingSelections);\n//get length of admingSelections object \nvar admingSelectionsLength = admingSelectionsKeys.length;\n//remove 2 items from Credentials if > AuthLoginCredentialsMaxLength\nif (admingSelectionsLength > admingSelectionsMaxLength)\n{ \n delete admingSelections[admingSelectionsKeys[0]];\n delete admingSelections[admingSelectionsKeys[1]];\n}\n\n\n\n//set admingSelections to users accessing this page\nif (!admingSelections[socketid])\n{\n admingSelections[socketid] = {};\n admingSelections[socketid]['currentUser'] = currentUser;\n}\nelse\n{\n admingSelections[socketid]['currentUser'] = currentUser;\n}\n\n msg.error = false;\n msg.currentUser = currentUser;\n msg.email = authUsers[currentUser].email;\n msg.role = authUsers[currentUser].role;\n msg.firstname = authUsers[currentUser].firstname;\n msg.lastname = authUsers[currentUser].lastname;\n msg.info = authUsers[currentUser].info;\n \n msg.topic = 'User: '+currentUser;\n msg.payload = 'email: '+authUsers[currentUser].email+'
role: '+authUsers[currentUser].role+'
firstname: '+authUsers[currentUser].firstname+'
lastname: '+authUsers[currentUser].lastname+'
info: '+authUsers[currentUser].info+'
';\n return msg;\n \n \n \n \n \n \n \n \n \n \n \n \n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 710, "y": 2340, "wires": [ [ "2803a8aa6f900add" ] ] }, { "id": "cf70eeeac4eeb453", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 6, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 1110, "y": 2620, "wires": [] }, { "id": "60517d4c5eb0ea3b", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 11, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 510, "y": 2820, "wires": [] }, { "id": "ef82643f4ce48dfb", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 3, "width": "2", "height": "1", "passthru": false, "label": "Edit Role", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 220, "y": 2380, "wires": [ [ "4e29658693b680e7" ] ] }, { "id": "e3f6e839411b862a", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 10, "width": "3", "height": "1", "passthru": false, "label": "Delete User", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 230, "y": 2740, "wires": [ [ "357ea85512f46ffd" ] ] }, { "id": "760df7be0e91b1b7", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 9, "width": "3", "height": "1", "passthru": false, "label": "Add User", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 220, "y": 2660, "wires": [ [ "7d3c0fbeb85edcbe" ] ] }, { "id": "d6bf1b639f3dbac0", "type": "ui_button", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Administrator", "group": "205ac72e296cb65f", "order": 8, "width": "0", "height": "0", "passthru": false, "label": "Administrator", "tooltip": "", "color": "#0094CE", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 130, "y": 2120, "wires": [ [ "f62511be2c967bce" ] ] }, { "id": "bbf46b0ed5727811", "type": "ui_toast", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2120, "wires": [] }, { "id": "46c5ebccf05a7d75", "type": "ui_text", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "group": "205ac72e296cb65f", "order": 5, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 430, "y": 2080, "wires": [] }, { "id": "749f325fc285f8a0", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Password Requirements", "group": "cc7d7ea92ffb628f", "order": 12, "width": 0, "height": 0, "passthru": false, "label": "Password Requirements", "tooltip": "", "color": "black", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 270, "y": 2820, "wires": [ [] ] }, { "id": "692d93619ad1760d", "type": "ui_numeric", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Minimum Length", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 13, "width": 0, "height": 0, "wrap": false, "passthru": false, "topic": "topic", "topicType": "msg", "format": "{{value}}", "min": "4", "max": "32", "step": 1, "x": 380, "y": 2860, "wires": [ [ "903e919ea1e8c12d" ] ] }, { "id": "1232d57e1ee6738d", "type": "ui_switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Require an Uppercase", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 14, "width": "5", "height": "1", "passthru": false, "decouple": "true", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 400, "y": 2900, "wires": [ [ "5d29a0a5d53555ab" ] ] }, { "id": "d849457489f03c43", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 15, "width": "1", "height": "1", "name": "true/false", "label": "", "format": "{{msg.payload}}", "layout": "col-center", "x": 360, "y": 2940, "wires": [] }, { "id": "a30b2258aa619d39", "type": "ui_switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Require an Lowercase", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 16, "width": "5", "height": "1", "passthru": false, "decouple": "true", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 400, "y": 2980, "wires": [ [ "7b0e31885e56d55d" ] ] }, { "id": "3837523c2fbc3913", "type": "ui_switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Require a Number", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 18, "width": "5", "height": "1", "passthru": false, "decouple": "true", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 390, "y": 3060, "wires": [ [ "0e72439280702488" ] ] }, { "id": "e5f88c7039988043", "type": "ui_switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Require a SpecialChar", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 20, "width": "5", "height": "1", "passthru": false, "decouple": "true", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 400, "y": 3140, "wires": [ [ "d5185aadb4aa24cf" ] ] }, { "id": "874d03e55576b320", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 22, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 510, "y": 3180, "wires": [] }, { "id": "f371f7073daed926", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Email", "group": "cc7d7ea92ffb628f", "order": 23, "width": 0, "height": 0, "passthru": false, "label": "Email", "tooltip": "", "color": "black", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 130, "y": 3220, "wires": [ [] ] }, { "id": "b85660bbaa59143f", "type": "ui_switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Email Support Enabled", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 24, "width": "5", "height": "1", "passthru": false, "decouple": "true", "topic": "topic", "topicType": "msg", "style": "", "onvalue": "true", "onvalueType": "bool", "onicon": "", "oncolor": "", "offvalue": "false", "offvalueType": "bool", "officon": "", "offcolor": "", "animate": false, "x": 400, "y": 3220, "wires": [ [ "f2a5c454e9b5322a" ] ] }, { "id": "fdadde907d2ccd04", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Log", "group": "cc7d7ea92ffb628f", "order": 27, "width": 0, "height": 0, "passthru": false, "label": "Log", "tooltip": "", "color": "black", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 130, "y": 3300, "wires": [ [] ] }, { "id": "829b6a38194816ab", "type": "ui_numeric", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "label": "Log Length", "tooltip": "", "group": "cc7d7ea92ffb628f", "order": 28, "width": 0, "height": 0, "wrap": false, "passthru": false, "topic": "topic", "topicType": "msg", "format": "{{value}}", "min": "25", "max": "2000", "step": "25", "x": 370, "y": 3300, "wires": [ [ "3fe082c1d5759802" ] ] }, { "id": "b3b68b81ab81ee1c", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 26, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 510, "y": 3260, "wires": [] }, { "id": "556a7ff6edf3abc7", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 29, "width": 0, "height": 0, "passthru": false, "label": "Refresh Log", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 150, "y": 3340, "wires": [ [ "dc72470f226e363b" ] ] }, { "id": "b16235d4fd175118", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 31, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 670, "y": 3260, "wires": [] }, { "id": "d33d69103a8d833e", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst user = msg.currentUser;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //Get admingSelections else create it\n var admingSelections = global.get('admingSelections')||{};\n //remove user submited to admingSelection by socketid\n delete admingSelections[socketid].currentUser;\n global.set('admingSelections', admingSelections);\n \n //change role\n var authUsers = global.get('authUsers')||{};\n if (authUsers[user].role === \"admin\") {\n authUsers[user].role = \"user\";\n msg.usertest = true;\n msg.authUsers = authUsers;\n }\n else if (authUsers[user].role === \"user\") { \n authUsers[user].role = \"admin\";\n msg.usertest = false;\n msg.authUsers = authUsers;\n }\n global.set('authUsers', authUsers);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' changed '+user+' role to: '+ authUsers[user].role +' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = user+' role now '+authUsers[user].role;\n msg.authUsers = authUsers;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2400, "wires": [ [ "cedf95caf505837e", "dc89563da1a69c88", "2a09a2d7b3dfae3b" ] ] }, { "id": "4e29658693b680e7", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "select", "func": "const socketid = msg.socketid;\n//Get admingSelections else create it\nconst admingSelections = global.get('admingSelections')||{};\nconst authUsers = global.get('authUsers')||{};\nvar newrole;\n\n//get user selected\nif (admingSelections.hasOwnProperty(socketid) && admingSelections[socketid].hasOwnProperty('currentUser')) {\n const currentUser = admingSelections[socketid].currentUser;\n const userrole = authUsers[currentUser].role\n msg.error = false;\n msg.currentUser = currentUser;\n msg.userrole = userrole;\n msg.topic = 'User: '+currentUser+' has a role: '+userrole;\n if (userrole === 'user') {\n newrole = 'admin';\n }\n else if (userrole === 'admin') {\n newrole = 'user';\n }\n msg.payload = 'Are you sure you want to make their role: '+newrole;\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'No User Selected';\n msg.payload = 'Please Select a User';\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 230, "y": 2420, "wires": [ [ "8e6b2fbedaf9f779" ] ] }, { "id": "95f0c6145665b641", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 510, "y": 2380, "wires": [ [] ] }, { "id": "8e6b2fbedaf9f779", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 370, "y": 2400, "wires": [ [ "95f0c6145665b641" ], [ "13e040673443d5ab" ] ] }, { "id": "13e040673443d5ab", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "Cancel", "raw": false, "topic": "", "name": "", "x": 510, "y": 2420, "wires": [ [ "86e703b77ce6037d" ] ] }, { "id": "86e703b77ce6037d", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Cancel", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 650, "y": 2400, "wires": [ [ "cedf95caf505837e" ], [ "add62737dbb5a787" ] ] }, { "id": "add62737dbb5a787", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 2420, "wires": [ [ "2508612c222daa77" ] ] }, { "id": "2508612c222daa77", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 860, "y": 2380, "wires": [ [ "d33d69103a8d833e" ] ] }, { "id": "dc89563da1a69c88", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2400, "wires": [] }, { "id": "1f4c57c7b94c6cba", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "select", "func": "const socketid = msg.socketid;\n//Get admingSelections else create it\nconst admingSelections = global.get('admingSelections')||{};\n\n//get user selected\nif (admingSelections.hasOwnProperty(socketid) && admingSelections[socketid].hasOwnProperty('currentUser')) {\n const currentUser = admingSelections[socketid].currentUser;\n msg.error = false;\n msg.currentUser = currentUser;\n msg.topic = 'This will Delete User: '+currentUser+' from the system';\n msg.payload = 'Are you sure you want contimue?';\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'No User Selected';\n msg.payload = 'Please Select a User';\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 230, "y": 2580, "wires": [ [ "7e03441d353c5cdb" ] ] }, { "id": "38f8a20df7659acf", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 510, "y": 2540, "wires": [ [] ] }, { "id": "7e03441d353c5cdb", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 370, "y": 2560, "wires": [ [ "38f8a20df7659acf" ], [ "9e093028cd88b473" ] ] }, { "id": "9b856e493b373db9", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 2580, "wires": [ [ "6eed64ec10a53d48" ] ] }, { "id": "6eed64ec10a53d48", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 860, "y": 2540, "wires": [ [ "717a680cf7b099b4" ] ] }, { "id": "b8996025fe824c8b", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2560, "wires": [] }, { "id": "717a680cf7b099b4", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst user = msg.currentUser;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //Get admingSelections else create it\n var admingSelections = global.get('admingSelections')||{};\n //remove user submited to admingSelection by socketid\n delete admingSelections[socketid].currentUser;\n global.set('admingSelections', admingSelections);\n \n //delete user\n var authUsers = global.get('authUsers')||{};\n delete authUsers[user];\n \n global.set('authUsers', authUsers);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' deleted user: '+user+' from the system | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'User: '+user+' Deleted';\n msg.authUsers = authUsers;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2560, "wires": [ [ "b8996025fe824c8b", "cedf95caf505837e", "2a09a2d7b3dfae3b" ] ] }, { "id": "c50b99dbafae42cf", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Cancel", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 650, "y": 2560, "wires": [ [ "19295afe8d6f16cf" ], [ "9b856e493b373db9" ] ] }, { "id": "9e093028cd88b473", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "Cancel", "raw": false, "topic": "", "name": "", "x": 510, "y": 2580, "wires": [ [ "c50b99dbafae42cf" ] ] }, { "id": "bea388cc2090053a", "type": "ui_dropdown", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Pending Users", "label": "", "tooltip": "", "place": "Select a User", "group": "cc7d7ea92ffb628f", "order": 8, "width": 0, "height": 0, "passthru": false, "multiple": false, "options": [], "payload": "", "topic": "topic", "topicType": "msg", "x": 520, "y": 2620, "wires": [ [ "a97536cfb74f066f" ] ] }, { "id": "42e24d946b45716a", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Pending Users", "group": "cc7d7ea92ffb628f", "order": 7, "width": 0, "height": 0, "passthru": false, "label": "Pending Users", "tooltip": "", "color": "black", "bgcolor": "white", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 1280, "y": 2620, "wires": [ [] ] }, { "id": "6a682b3f32705976", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "Create an arry of Pending Users", "func": "const newUesrRequests = global.get('newUesrRequests')||{};\n\n//Create an arry of Pending Users\nnewUsersNamesArray = Object.keys(newUesrRequests);\n\nmsg.options = newUsersNamesArray\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 290, "y": 2620, "wires": [ [ "bea388cc2090053a" ] ] }, { "id": "2803a8aa6f900add", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 950, "y": 2340, "wires": [ [] ] }, { "id": "b8b39bdd437cc391", "type": "ui_button", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "group": "cc7d7ea92ffb628f", "order": 4, "width": "2", "height": "1", "passthru": false, "label": "Reset Pass", "tooltip": "", "color": "", "bgcolor": "", "icon": "", "payload": "", "payloadType": "str", "topic": "topic", "topicType": "msg", "x": 230, "y": 2460, "wires": [ [ "c6d15893659de90e" ] ] }, { "id": "c0a76f2f53cb773a", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 510, "y": 2460, "wires": [ [] ] }, { "id": "df652bc2903db105", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 370, "y": 2480, "wires": [ [ "c0a76f2f53cb773a" ], [ "72e81bc851bed530" ] ] }, { "id": "72e81bc851bed530", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "Cancel", "raw": false, "topic": "", "name": "", "x": 510, "y": 2500, "wires": [ [ "3b92ee60fd73213a" ] ] }, { "id": "3b92ee60fd73213a", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Cancel", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 650, "y": 2460, "wires": [ [ "cedf95caf505837e" ], [ "4765a984bb3fe5f4" ] ] }, { "id": "4765a984bb3fe5f4", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 2500, "wires": [ [ "7c6d5c44c16d806a" ] ] }, { "id": "7c6d5c44c16d806a", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 860, "y": 2460, "wires": [ [ "768ec9889a3fa9c4" ] ] }, { "id": "c6d15893659de90e", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "select", "func": "const socketid = msg.socketid;\n//Get admingSelections else create it\nconst admingSelections = global.get('admingSelections')||{};\nconst authUsers = global.get('authUsers')||{};\nvar newrole;\n\n//get user selected\nif (admingSelections.hasOwnProperty(socketid) && admingSelections[socketid].hasOwnProperty('currentUser')) {\n const currentUser = admingSelections[socketid].currentUser;\n msg.error = false;\n msg.currentUser = currentUser;\n msg.topic = 'This will Reset User: '+currentUser+' Password';\n msg.payload = 'Are you sure you want contimue?';\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'No User Selected';\n msg.payload = 'Please Select a User';\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 230, "y": 2500, "wires": [ [ "df652bc2903db105" ] ] }, { "id": "768ec9889a3fa9c4", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "random 32char string", "func": "function randomString(length, chars) {\n var result = '';\n for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];\n return result;\n}\n//create a random 32 char string\nvar rString = randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\nmsg.rString = rString;\nmsg.rStringEncrypted = rString;\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2460, "wires": [ [ "cfb87687ae62b688" ] ] }, { "id": "cfb87687ae62b688", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "action": "encrypt", "field": "rStringEncrypted", "hash": "", "rounds": "4", "x": 1290, "y": 2460, "wires": [ [ "b2111a0bac8b432c" ] ] }, { "id": "b2111a0bac8b432c", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "password & MUI LOG", "func": "var authUsers = global.get('authUsers');\nvar muiLog = global.get('muiLog')||[];\nconst humanTimestamp = msg.humanTimestamp;\nvar socketip;\nconst socketid = msg.socketid;\nconst rStringEncrypted = msg.rStringEncrypted\nconst rString = msg.rString;\nconst currentUser = msg.currentUser;\n\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n socketip = AuthLoginCredentials[socketid]['ip'];\n }\n}\n\n//set new password for user\nauthUsers[currentUser].password = rStringEncrypted;\nglobal.set('authUsers', authUsers);\n\nvar newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+socketid+' Changed password of '+currentUser+' | socket - ' + socketid;\n//add new log item to the top of the array\nmuiLog.unshift(newLineInLog);\nglobal.set('muiLog', muiLog);\n\nmsg.topic = 'Password changed!';\nmsg.payload = 'User: '+currentUser+'
Password: '+rString+'
'+'

Copy and save the password!
Passwords in plain txt are not stored on the system';\nmsg.authUsers = authUsers;\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2500, "wires": [ [ "5fedd441611656e2", "cedf95caf505837e", "2a09a2d7b3dfae3b" ] ] }, { "id": "5fedd441611656e2", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1290, "y": 2500, "wires": [ [] ] }, { "id": "a97536cfb74f066f", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "admin selections", "func": "const socketid = msg.socketid;\nconst socketip = msg.socketip;\nconst newUesrRequests = global.get('newUesrRequests')||{};\nvar currentUser = msg.payload;\n\n\n//Get admingSelections else create it\nvar admingSelections = global.get('admingSelections')||{};\n\n\n//clean up admingSelections so it does not overflow.\nvar admingSelectionsMaxLength = 1000;\n//get keys admingSelections object \nvar admingSelectionsKeys = Object.keys(admingSelections);\n//get length of admingSelections object \nvar admingSelectionsLength = admingSelectionsKeys.length;\n//remove 2 items from Credentials if > AuthLoginCredentialsMaxLength\nif (admingSelectionsLength > admingSelectionsMaxLength)\n{ \n delete admingSelections[admingSelectionsKeys[0]];\n delete admingSelections[admingSelectionsKeys[1]];\n}\n\n\n\n//set admingSelections \nif (!admingSelections[socketid])\n{\n admingSelections[socketid] = {};\n admingSelections[socketid]['newUesrRequestsUser'] = currentUser;\n}\nelse\n{\n admingSelections[socketid]['newUesrRequestsUser'] = currentUser;\n}\n\n msg.error = false;\n msg.currentUser = currentUser;\n msg.email = newUesrRequests[currentUser].userEmail;\n msg.role = 'user';\n msg.firstname = newUesrRequests[currentUser].firstName;\n msg.lastname = newUesrRequests[currentUser].lastName;\n msg.info = newUesrRequests[currentUser].info;\n \n msg.topic = 'User: '+currentUser;\n msg.payload = 'email: '+newUesrRequests[currentUser].userEmail+'
role: user
firstname: '+newUesrRequests[currentUser].firstName+'
lastname: '+newUesrRequests[currentUser].lastName+'
info: '+newUesrRequests[currentUser].info+'
'+'
IP address of user who created this account
'+newUesrRequests[currentUser].ip+'
';\n return msg;\n \n \n \n \n \n \n \n \n \n \n \n \n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 710, "y": 2620, "wires": [ [ "abaccc336ca1abe1" ] ] }, { "id": "abaccc336ca1abe1", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 950, "y": 2620, "wires": [ [] ] }, { "id": "5294a4074ede5ddb", "type": "function", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "Remove Credentials", "func": "const socketid = msg.socketid;\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\nvar admingSelections = global.get('admingSelections')||{};\n//RemoveAuthLoginCredentials when user connects to stop hijacking attempt of socketid\ndelete AuthLoginCredentials[socketid];\ndelete admingSelections[socketid];\n\n\nglobal.set('AuthLoginCredentials', AuthLoginCredentials);\nglobal.set('admingSelections', admingSelections);\n\n//AuthLoginCredentials = global.get('AuthLoginCredentials');\n//msg.AuthLoginCredentials = AuthLoginCredentials;\n\n \nreturn msg;\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 560, "wires": [ [ "ba9a1bd25f9b4695" ] ] }, { "id": "ba9a1bd25f9b4695", "type": "debug", "z": "665e920cca795df7", "g": "3e6d216dbf2a0833", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 1310, "y": 560, "wires": [] }, { "id": "89e665156db7bb96", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst user = msg.currentUser;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //Get newUesrRequests else create it\n var newUesrRequests = global.get('newUesrRequests')||{};\n //add user submited to admingSelections by socketid to authUsers Object\n var authUsers = global.get('authUsers')||{};\n \n authUsers[user] = {};\n authUsers[user]['password'] = newUesrRequests[user].userPassword;\n authUsers[user]['email'] = newUesrRequests[user].userEmail;\n authUsers[user]['role'] = newUesrRequests[user].userRole;\n authUsers[user]['firstname'] = newUesrRequests[user].firstName;\n authUsers[user]['lastname'] = newUesrRequests[user].lastName;\n authUsers[user]['info'] = newUesrRequests[user].info;\n \n global.set('authUsers', authUsers);\n \n //now that user is added ... remove from newUesrRequests object\n delete newUesrRequests[user];\n global.set('newUesrRequests', newUesrRequests);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' added '+user+' to system | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = ' added User: '+user+' to system'\n msg.authUsers = authUsers;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2680, "wires": [ [ "46b15d4ecebba222", "2a09a2d7b3dfae3b", "6a682b3f32705976" ] ] }, { "id": "8e3017276d094dc2", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 510, "y": 2660, "wires": [ [] ] }, { "id": "edb9e9ec6363f17a", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 370, "y": 2680, "wires": [ [ "8e3017276d094dc2" ], [ "22a5ca311d37efe6" ] ] }, { "id": "22a5ca311d37efe6", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "Cancel", "raw": false, "topic": "", "name": "", "x": 510, "y": 2700, "wires": [ [ "cfe7e3def607a084" ] ] }, { "id": "cfe7e3def607a084", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Cancel", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 650, "y": 2680, "wires": [ [ "6a682b3f32705976" ], [ "567bbcd41053d5f4" ] ] }, { "id": "567bbcd41053d5f4", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 2700, "wires": [ [ "b2295c412e19509f" ] ] }, { "id": "b2295c412e19509f", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 860, "y": 2660, "wires": [ [ "89e665156db7bb96" ] ] }, { "id": "46b15d4ecebba222", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2680, "wires": [] }, { "id": "7d3c0fbeb85edcbe", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "select", "func": "const socketid = msg.socketid;\n//Get admingSelections else create it\nconst admingSelections = global.get('admingSelections')||{};\n\n//get user selected\nif (admingSelections.hasOwnProperty(socketid) && admingSelections[socketid].hasOwnProperty('newUesrRequestsUser')) {\n const currentUser = admingSelections[socketid].newUesrRequestsUser;\n msg.error = false;\n msg.currentUser = currentUser;\n msg.topic = 'This will Add User: '+currentUser+' to the system';\n msg.payload = 'Are you sure you want contimue?';\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'No User Selected';\n msg.payload = 'Please Select a User';\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 230, "y": 2700, "wires": [ [ "edb9e9ec6363f17a" ] ] }, { "id": "a98cd8cad8b7a555", "type": "file", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "filename": "./data/auth/authUsers.dat", "appendNewline": false, "createDir": true, "overwriteFile": "true", "encoding": "none", "x": 1250, "y": 2820, "wires": [ [] ] }, { "id": "a44cb5a9766ad758", "type": "json", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "action": "str", "pretty": false, "x": 1070, "y": 2820, "wires": [ [ "a98cd8cad8b7a555" ] ] }, { "id": "2a09a2d7b3dfae3b", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "set msg.payload to msg.authUsers", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "authUsers", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1220, "y": 2780, "wires": [ [ "a44cb5a9766ad758" ] ] }, { "id": "c1fee42ba43aa8f7", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst user = msg.currentUser;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //Get newUesrRequests else create it\n var newUesrRequests = global.get('newUesrRequests')||{};\n \n //remove user from newUesrRequests object\n delete newUesrRequests[user];\n global.set('newUesrRequests', newUesrRequests);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Deleted '+user+' from system | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = user+' role now '+authUsers[user].role;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1080, "y": 2740, "wires": [ [ "e4582b4aeab64608" ] ] }, { "id": "8d4dd41316215700", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 510, "y": 2740, "wires": [ [] ] }, { "id": "1bd6545b19dcb9e4", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 370, "y": 2760, "wires": [ [ "8d4dd41316215700" ], [ "8812453143c547ac" ] ] }, { "id": "8812453143c547ac", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "Cancel", "raw": false, "topic": "", "name": "", "x": 510, "y": 2780, "wires": [ [ "f94f2961831ae700" ] ] }, { "id": "f94f2961831ae700", "type": "switch", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Cancel", "vt": "str" }, { "t": "eq", "v": "OK", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 650, "y": 2760, "wires": [ [], [ "d8bd186e8471f5c0" ] ] }, { "id": "d8bd186e8471f5c0", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 850, "y": 2780, "wires": [ [ "bb15ccbd5234681f" ] ] }, { "id": "bb15ccbd5234681f", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 860, "y": 2740, "wires": [ [ "c1fee42ba43aa8f7" ] ] }, { "id": "e4582b4aeab64608", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2740, "wires": [] }, { "id": "357ea85512f46ffd", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "select", "func": "const socketid = msg.socketid;\n//Get admingSelections else create it\nconst admingSelections = global.get('admingSelections')||{};\n\n//get user selected\nif (admingSelections.hasOwnProperty(socketid) && admingSelections[socketid].hasOwnProperty('newUesrRequestsUser')) {\n const currentUser = admingSelections[socketid].newUesrRequestsUser;\n msg.error = false;\n msg.currentUser = currentUser;\n msg.topic = 'This will remove Pending User\\'s Account Request for user: '+currentUser;\n msg.payload = 'Are you sure you want contimue?';\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'No User Selected';\n msg.payload = 'Please Select a User';\n return msg;\n}\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 230, "y": 2780, "wires": [ [ "1bd6545b19dcb9e4" ] ] }, { "id": "b9bf9e288df0d71b", "type": "ui_text", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "group": "205ac72e296cb65f", "order": 6, "width": 0, "height": 0, "name": "blank spacer", "label": "", "format": "", "layout": "col-center", "x": 590, "y": 2080, "wires": [] }, { "id": "27a26fc8fcefc195", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "get settings", "func": "const authSettings = global.get('authSettings')||{};\nconst muiLog = global.get('muiLog')||{};\n\nmsg.password_mustContainMinCharOf = authSettings.passReq.mustContainMinCharOf;\nmsg.password_mustContainMinOneUppercase = authSettings.passReq.mustContainMinOneUppercase;\nmsg.password_mustContainMinOneLowercase = authSettings.passReq.mustContainMinOneLowercase;\nmsg.password_mustContainMinOneNumber = authSettings.passReq.mustContainMinOneNumber;\nmsg.password_mustContainMinOneSpecialChar = authSettings.passReq.mustContainMinOneSpecialChar;\nmsg.password_emailSupportEnabled = authSettings.emailSupportEnabled;\nmsg.password_maxmuiLogLength = authSettings.muiLog.maxmuiLogLength;\nmsg.log_maxmuiLogLength = authSettings.muiLog.maxmuiLogLength\n\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 150, "y": 2860, "wires": [ [ "76e520ee7aa09625", "315a81f83240dc1b", "19b1a4821660a0c2", "2f18b91432937f14", "d1b859d356ebf858", "2622b0747be31ef2", "794bf4721284e6da", "dc72470f226e363b" ] ] }, { "id": "76e520ee7aa09625", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_mustContainMinCharOf", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 2860, "wires": [ [ "692d93619ad1760d" ] ], "l": false }, { "id": "315a81f83240dc1b", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_mustContainMinOneUppercase", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 2920, "wires": [ [ "1232d57e1ee6738d", "d849457489f03c43" ] ], "l": false }, { "id": "19b1a4821660a0c2", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_mustContainMinOneLowercase", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 2980, "wires": [ [ "a30b2258aa619d39", "84018a4e16ba25d3" ] ], "l": false }, { "id": "2f18b91432937f14", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_mustContainMinOneNumber", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 3080, "wires": [ [ "3837523c2fbc3913", "ac6af2069acff936" ] ], "l": false }, { "id": "d1b859d356ebf858", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_mustContainMinOneSpecialChar", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 3160, "wires": [ [ "e5f88c7039988043", "73763d67ee7418cd" ] ], "l": false }, { "id": "2622b0747be31ef2", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "password_emailSupportEnabled", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 3240, "wires": [ [ "b85660bbaa59143f", "b0dd4065f2570aa5" ] ], "l": false }, { "id": "794bf4721284e6da", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "log_maxmuiLogLength", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 3300, "wires": [ [ "829b6a38194816ab" ] ], "l": false }, { "id": "ef949552aab281c6", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.passReq.mustContainMinCharOf = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Password Minimum Length to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Password Minimum Length: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 2860, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "afcc8b30d5d0779d", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.passReq.mustContainMinOneUppercase = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Require an Uppercase to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Require an Uppercase: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 2900, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "84018a4e16ba25d3", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 17, "width": "1", "height": "1", "name": "true/false", "label": "", "format": "{{msg.payload}}", "layout": "col-center", "x": 360, "y": 3020, "wires": [] }, { "id": "ac6af2069acff936", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 19, "width": "1", "height": "1", "name": "true/false", "label": "", "format": "{{msg.payload}}", "layout": "col-center", "x": 360, "y": 3100, "wires": [] }, { "id": "73763d67ee7418cd", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 21, "width": "1", "height": "1", "name": "true/false", "label": "", "format": "{{msg.payload}}", "layout": "col-center", "x": 360, "y": 3180, "wires": [] }, { "id": "b0dd4065f2570aa5", "type": "ui_text", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "order": 25, "width": "1", "height": "1", "name": "true/false", "label": "", "format": "{{msg.payload}}", "layout": "col-center", "x": 360, "y": 3260, "wires": [] }, { "id": "5da54d6b0e5fb715", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.passReq.mustContainMinOneLowercase = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Require an Lowercase to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Require an Lowercase: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 2980, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "a38b8c64e81328bd", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.passReq.mustContainMinOneNumber = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Require a Number to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Require a Number: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 3060, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "3a50847695423c17", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.passReq.mustContainMinOneSpecialChar = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Require a SpecialChar to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Require a SpecialChar: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 3140, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "e3e4160d4d060109", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.emailSupportEnabled = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Email Support Enabled to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Email Support Enabled: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 3220, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "609075148e8d6156", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "execute & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst payload = msg.payload;\nvar muiLog = global.get('muiLog')||[];\n\n//get socketip first.\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n //update setting\n var authSettings = global.get('authSettings')||{};\n authSettings.muiLog.maxmuiLogLength = payload;\n global.set('authSettings', authSettings);\n \n var newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | '+AuthLoginCredentials[socketid].userName+' Changed Log Length to '+payload.toString()+' | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n global.set('muiLog', muiLog);\n msg.topic = \"\";\n msg.payload = 'Log Length: '+payload.toString();\n msg.authSettings = authSettings;\n return msg;\n\n }\n}\n\n\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1040, "y": 3300, "wires": [ [ "27a26fc8fcefc195", "f5d4d11e49df0ac2", "29e6fae85c7bd9e4" ] ] }, { "id": "f5d4d11e49df0ac2", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "payload to authSettings", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "authSettings", "tot": "msg" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 1310, "y": 2900, "wires": [ [ "9e8b701e4d8d9b71" ] ] }, { "id": "9e8b701e4d8d9b71", "type": "json", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "property": "payload", "action": "str", "pretty": false, "x": 1250, "y": 2940, "wires": [ [ "f3f8b792aa6cca53" ] ] }, { "id": "f3f8b792aa6cca53", "type": "file", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "filename": "./data/auth/authSettings.dat", "appendNewline": false, "createDir": true, "overwriteFile": "true", "encoding": "none", "x": 1320, "y": 2980, "wires": [ [] ] }, { "id": "29e6fae85c7bd9e4", "type": "ui_toast", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 2860, "wires": [] }, { "id": "dc72470f226e363b", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "payload", "pt": "msg", "to": "muiLog", "tot": "global" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 255, "y": 3340, "wires": [ [ "fc20266d8615f014" ] ], "l": false }, { "id": "fc20266d8615f014", "type": "split", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "splt": "\\n", "spltType": "str", "arraySplt": 1, "arraySpltType": "len", "stream": false, "addname": "", "x": 490, "y": 3340, "wires": [ [ "e135dfbceda48a37" ] ] }, { "id": "2df4eb2550821d38", "type": "join", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "mode": "custom", "build": "string", "property": "payload", "propertyType": "msg", "key": "topic", "joiner": "\\n\\r", "joinerType": "str", "accumulate": false, "timeout": "", "count": "", "reduceRight": false, "reduceExp": "", "reduceInit": "", "reduceInitType": "", "reduceFixup": "", "x": 870, "y": 3340, "wires": [ [ "4cdc725d19c730c0" ] ] }, { "id": "e135dfbceda48a37", "type": "function", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "func": "var payload = msg.payload;\npayload = payload+'

';\nmsg.payload = payload;\n\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 640, "y": 3340, "wires": [ [ "2df4eb2550821d38" ] ] }, { "id": "3cd3e0a3f8ba2ebc", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 2860, "wires": [ [ "ef949552aab281c6" ] ] }, { "id": "903e919ea1e8c12d", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 2860, "wires": [ [ "3cd3e0a3f8ba2ebc" ] ] }, { "id": "c0e4757fbf245ca7", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 2900, "wires": [ [ "afcc8b30d5d0779d" ] ] }, { "id": "5d29a0a5d53555ab", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 2900, "wires": [ [ "c0e4757fbf245ca7" ] ] }, { "id": "eee84f32924154a4", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 2980, "wires": [ [ "5da54d6b0e5fb715" ] ] }, { "id": "7b0e31885e56d55d", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 2980, "wires": [ [ "eee84f32924154a4" ] ] }, { "id": "3b97d7edfcb41a39", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 3060, "wires": [ [ "a38b8c64e81328bd" ] ] }, { "id": "0e72439280702488", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 3060, "wires": [ [ "3b97d7edfcb41a39" ] ] }, { "id": "df3ebb2a55542494", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 3140, "wires": [ [ "3a50847695423c17" ] ] }, { "id": "d5185aadb4aa24cf", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 3140, "wires": [ [ "df3ebb2a55542494" ] ] }, { "id": "3b01373bf7149497", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 3220, "wires": [ [ "e3e4160d4d060109" ] ] }, { "id": "f2a5c454e9b5322a", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 3220, "wires": [ [ "3b01373bf7149497" ] ] }, { "id": "04cb596958a24c45", "type": "moment", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 820, "y": 3300, "wires": [ [ "609075148e8d6156" ] ] }, { "id": "3fe082c1d5759802", "type": "change", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 610, "y": 3300, "wires": [ [ "04cb596958a24c45" ] ] }, { "id": "4cdc725d19c730c0", "type": "ui_template", "z": "665e920cca795df7", "g": "7f4066b5a86a06c0", "group": "cc7d7ea92ffb628f", "name": "", "order": 30, "width": 0, "height": 0, "format": "
", "storeOutMessages": true, "fwdInMessages": true, "resendOnRefresh": true, "templateScope": "local", "x": 1020, "y": 3340, "wires": [ [] ] }, { "id": "9ecffb3948144e55", "type": "function", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "Chek user for admin role & MUI LOG", "func": "const socketid = msg.socketid;\nconst humanTimestamp = msg.humanTimestamp;\nconst authSettings = global.get('authSettings')||{};\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n \n \n //Get get the current userName that clicked the button\n const userName = AuthLoginCredentials[socketid].userName||{};\n const role = AuthLoginCredentials[socketid].role||{};\n \n \n if (role === 'admin') {\n msg.error = false;\n msg.url = '/ui/#!/5?socketid='+socketid;\n msg.topic = '';\n msg.payload = 'AdministratortAdministrator';\n return msg;\n }\n if (role === 'user') {\n newLineInLog = 'Relative URL: /ui/#!/5 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Was Declined Accessed Administrator Button | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = true;\n msg.timeout = 2;\n msg.topic = 'Access Denied';\n msg.payload = 'You lack proper user role';\n return msg;\n }\n \n msg.test = 'test';\n msg.role = role;\n return msg;\n \n \n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n msg.timeout = 2;\n msg.url = '/ui/#!/1?socketid='+socketid;\n msg.topic = '';\n msg.payload = 'LoginLogin';\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n msg.timeout = 2;\n msg.url = '/ui/#!/1?socketid='+socketid;\n msg.topic = '';\n msg.payload = 'LoginLogin';\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 2120, "wires": [ [ "bbf46b0ed5727811" ] ] }, { "id": "f62511be2c967bce", "type": "change", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 410, "y": 2120, "wires": [ [ "152be4649cf73f00" ] ] }, { "id": "152be4649cf73f00", "type": "moment", "z": "665e920cca795df7", "g": "5582e0b7d2b0efc4", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 620, "y": 2120, "wires": [ [ "9ecffb3948144e55" ] ] }, { "id": "39e131f042f8f456", "type": "comment", "z": "665e920cca795df7", "g": "24ea45ad1772c194", "name": "Look at Automation Tab 6 below for example of secureing your page", "info": "", "x": 280, "y": 240, "wires": [] }, { "id": "ebf06ebc2e218c6d", "type": "comment", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "AccountRecovery Tab 3", "info": "", "x": 140, "y": 1360, "wires": [] }, { "id": "3e5f0d93ebee7a01", "type": "ui_form", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Account Recovery", "label": "Enter the Username or email
used to create your account", "group": "a40bb0d9c16471df", "order": 1, "width": 0, "height": 0, "options": [ { "label": "Username or email", "value": "userNameorEmail", "type": "text", "required": false, "rows": null } ], "formValue": { "userNameorEmail": "" }, "payload": "", "submit": "submit", "cancel": "", "topic": "topic", "topicType": "msg", "splitLayout": "", "x": 150, "y": 1400, "wires": [ [ "7eb72b7912f3dc67" ] ] }, { "id": "7eb72b7912f3dc67", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Username/Email exists?", "func": "const socketid = msg.socketid;\nconst authUsers = global.get('authUsers');\nconst userNameorEmail = msg.payload.userNameorEmail;\nconst authSettings = global.get('authSettings');\nvar authUsersNamesArray = [];\nvar authUsersEmailsArray = [];\n\n//populate an arry of with Current userNames stored in authUsers object\nauthUsersNamesArray = Object.keys(authUsers);\n//check if userSubmition is one of the userNames\nif (authUsersNamesArray.includes(userNameorEmail)) {\n msg.error = false;\n msg.userName = userNameorEmail;\n return msg;\n}\n//populate an arry with Current userEmails stored in authUsers object\nauthUsersNamesArray.forEach(function(eachUserName) {\n let eachEmail = authUsers[eachUserName].email;\n authUsersEmailsArray.push(eachEmail);\n});\n//check if userSubmition is one of the userEmails\n//lowerCase the email submition\nvar userNameorEmailtoLowercase = userNameorEmail.toLowerCase();\nif (authUsersEmailsArray.includes(userNameorEmailtoLowercase)) {\n //we want the userName attached to that email\n msg.error = false;\n //we want the userName attached to that email\n msg.userName = authUsersNamesArray[authUsersEmailsArray.indexOf(userNameorEmailtoLowercase)];\n return msg;\n}\nelse {\n msg.error = true;\n msg.topic = 'Can not find Username or email';\n msg.payload = 'Try again or create a new account';\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 370, "y": 1400, "wires": [ [ "e8adc61cd834c40d" ] ] }, { "id": "7c6a04ab7699c0f1", "type": "switch", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "", "property": "error", "propertyType": "msg", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 990, "y": 1400, "wires": [ [ "16baf3917e6b540b" ], [ "eb16292409df87d1" ] ] }, { "id": "16baf3917e6b540b", "type": "ui_toast", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 1290, "y": 1400, "wires": [ [] ] }, { "id": "eb16292409df87d1", "type": "switch", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "email Support Enabled?", "property": "authSettings.emailSupportEnabled", "propertyType": "global", "rules": [ { "t": "true" }, { "t": "false" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 170, "y": 1440, "wires": [ [ "20233496ddb3b129" ], [ "e0ce03479bcb45b9" ] ] }, { "id": "22e21411782f5db5", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "random 32char string", "func": "function randomString(length, chars) {\n var result = '';\n for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];\n return result;\n}\n//create a random 32 char string\nvar rString = randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');\nmsg.rString = rString;\nmsg.rStringEncrypted = rString;\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 460, "y": 1480, "wires": [ [ "20544c1dd87f617e" ] ] }, { "id": "4b5a06c88fb9185c", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Format email with new password for user", "func": "var authUsers = global.get('authUsers');\nconst userName = msg.userName;\nconst rStringEncrypted = msg.rStringEncrypted\nconst rString = msg.rString;\n\n//set new password for user\nauthUsers[userName].password = rStringEncrypted;\nglobal.set('authUsers', authUsers);\n\n\n\n//format email\nmsg.to = authUsers[userName].email;\nmsg.topic = \"Account Recovery\";\nmsg.payload = \"Please login with...\"+\"\\r\\n\"+\"\\r\\n\"+\"Username: \"+userName+\"\\r\\n\"+\"Password: \"+rString+\"\\r\\n\"+\"\\r\\n\"+\"You can change the password after loggin in by going to the Account tab on the left and entering a new Password\"+\"\\r\\n\"+\"\\r\\n\"+\"Thank you!\";\n\n\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1020, "y": 1480, "wires": [ [ "70129261bc9dbe85" ] ] }, { "id": "20544c1dd87f617e", "type": "twin-bcrypt", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "", "action": "encrypt", "field": "rStringEncrypted", "hash": "", "rounds": "4", "x": 770, "y": 1480, "wires": [ [ "4b5a06c88fb9185c" ] ] }, { "id": "e8adc61cd834c40d", "type": "change", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "", "rules": [ { "t": "set", "p": "timestamp", "pt": "msg", "to": "", "tot": "date" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 590, "y": 1400, "wires": [ [ "57c79b7c52d7ec72" ] ] }, { "id": "57c79b7c52d7ec72", "type": "moment", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "", "topic": "", "input": "timestamp", "inputType": "msg", "inTz": "America/New_York", "adjAmount": 0, "adjType": "days", "adjDir": "add", "format": "Do MMMM YYYY HH:mm:ss z", "locale": "en-US", "output": "humanTimestamp", "outputType": "msg", "outTz": "America/New_York", "x": 800, "y": 1400, "wires": [ [ "7c6a04ab7699c0f1" ] ] }, { "id": "e0ce03479bcb45b9", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "newUesrRequests & MUI LOG", "func": "const socketid = msg.socketid;\nconst userName = msg.userName;\nconst authSettings = global.get('authSettings');\nconst humanTimestamp = msg.humanTimestamp;\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n newLineInLog = 'Relative URL: /ui/#!/3 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Cant complete account recovery request - setup email to fix this | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n msg.topic = 'Warning, email support not enabled';\n msg.payload = 'Please contact your admin about resetting your password';\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 490, "y": 1520, "wires": [ [ "5e09b65ab3a367a2" ] ] }, { "id": "5e09b65ab3a367a2", "type": "ui_toast", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 770, "y": 1520, "wires": [ [ "8958446cb99e5abc" ] ] }, { "id": "8958446cb99e5abc", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to homepage\nmsg.url = '/ui/#!/0?socketid='+socketid;\n\nmsg.payload = 'HomeHome';\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1520, "wires": [ [ "58052a3c8d3ded4a" ] ] }, { "id": "58052a3c8d3ded4a", "type": "ui_toast", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1520, "wires": [] }, { "id": "70129261bc9dbe85", "type": "link out", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "email link out", "links": [ "1618be83e8776c89" ], "x": 1215, "y": 1480, "wires": [] }, { "id": "13a4c5f01a62d9d4", "type": "comment", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Email", "info": "", "x": 1310, "y": 1480, "wires": [] }, { "id": "20233496ddb3b129", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "newUesrRequests & MUI LOG", "func": "const socketid = msg.socketid;\nconst userName = msg.userName;\nconst authSettings = global.get('authSettings');\nconst humanTimestamp = msg.humanTimestamp;\nvar muiLog = global.get('muiLog')||[];\n\n//clean up muiLog so it does not overflow.\n//Set length of muiLog array, \nvar muiLogMaxLength = authSettings.muiLog.maxmuiLogLength;\n//get length of muiLog array \nvar muiLogLength = muiLog.length;\n//remove 2 items from muiLog if > muiLogMaxLength\nif (muiLogLength > muiLogMaxLength) { \n muiLog.splice(muiLogLength - 2, 2);\n}\n\n//get socketip first. If user does not have one send them back to login page as they direct linked in here\n//Get AuthLoginCredentials else create it\nvar AuthLoginCredentials = global.get('AuthLoginCredentials')||{};\n//check that ip is in AuthLoginCredentials\nif (AuthLoginCredentials.hasOwnProperty(socketid)) {\n if (AuthLoginCredentials[socketid].hasOwnProperty('ip')) {\n const socketip = AuthLoginCredentials[socketid]['ip'];\n\n newLineInLog = 'Relative URL: /ui/#!/3 | ' + humanTimestamp + ' | IP - ' + socketip + ' | ' + 'user: ' + userName + ' Submitted a account recovery request | socket - ' + socketid;\n //add new log item to the top of the array\n muiLog.unshift(newLineInLog);\n msg.error = false;\n msg.topic = 'Request Submitted';\n msg.payload = 'Check your email tied to this account';\n return msg;\n }\n else //no ip found in AuthLoginCredentials send user to login page (this happens when they direct link to page and skip loggin page)\n {\n msg.error = true;\n return msg;\n }\n}\nelse // no AuthLoginCredentials found send user to login page (this happens when they direct link to page and skip loggin page)\n{\n msg.error = true;\n return msg;\n}\n\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 490, "y": 1440, "wires": [ [ "22e21411782f5db5", "a4515fe413e998b8" ] ] }, { "id": "ffc054e8d485e58e", "type": "ui_toast", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "position": "top right", "displayTime": "", "highlight": "", "sendall": false, "outputs": 0, "ok": "OK", "cancel": "", "raw": true, "topic": "", "name": "", "x": 1280, "y": 1440, "wires": [] }, { "id": "a4515fe413e998b8", "type": "ui_toast", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "position": "dialog", "displayTime": "3", "highlight": "", "sendall": false, "outputs": 1, "ok": "OK", "cancel": "", "raw": false, "topic": "", "name": "", "x": 770, "y": 1440, "wires": [ [ "de7243b5a17a049e" ] ] }, { "id": "de7243b5a17a049e", "type": "function", "z": "665e920cca795df7", "g": "7b26426dcc5af3d1", "name": "Format Payload for notification node", "func": "const socketid = msg.socketid;\n\nmsg.timeout = 2;\nmsg.topic = ``;\n//send user to homepage\nmsg.url = '/ui/#!/0?socketid='+socketid;\n\nmsg.payload = 'HomeHome';\nreturn msg;\n", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1030, "y": 1440, "wires": [ [ "ffc054e8d485e58e" ] ] }, { "id": "f5f7cada415a15e8", "type": "ui_group", "name": "Default", "tab": "d9365e0f.e1bf6", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "1deed69fcda2c602", "type": "ui_group", "name": "Default", "tab": "5c4d39b567c71a51", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "62b44eba9c39b679", "type": "ui_group", "name": "Default", "tab": "db5f25b4b4c5ca8e", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "4edfae8b.b8925", "type": "ui_group", "name": "Tab", "tab": "69e3b08450578e6c", "order": 2, "disp": false, "width": "25", "collapse": false }, { "id": "205ac72e296cb65f", "type": "ui_group", "name": "Default", "tab": "5142458f484f3e53", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "cc7d7ea92ffb628f", "type": "ui_group", "name": "Default", "tab": "152c5964d720afc7", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "a40bb0d9c16471df", "type": "ui_group", "name": "Default", "tab": "fc0af643ec51fbb4", "order": 1, "disp": false, "width": "6", "collapse": false }, { "id": "d9365e0f.e1bf6", "type": "ui_tab", "name": "Login", "icon": "lock", "order": 2, "disabled": false, "hidden": true }, { "id": "5c4d39b567c71a51", "type": "ui_tab", "name": "Automation", "icon": "dashboard", "order": 7, "disabled": false, "hidden": false }, { "id": "db5f25b4b4c5ca8e", "type": "ui_tab", "name": "New Account", "icon": "dashboard", "order": 3, "disabled": false, "hidden": true }, { "id": "69e3b08450578e6c", "type": "ui_tab", "name": "Home", "icon": "dashboard", "order": 1, "disabled": false, "hidden": false }, { "id": "5142458f484f3e53", "type": "ui_tab", "name": "Account", "icon": "dashboard", "order": 5, "disabled": false, "hidden": false }, { "id": "152c5964d720afc7", "type": "ui_tab", "name": "Admin", "icon": "dashboard", "order": 6, "disabled": false, "hidden": true }, { "id": "fc0af643ec51fbb4", "type": "ui_tab", "name": "AccountRecovery", "icon": "dashboard", "order": 4, "disabled": false, "hidden": true } ]