Click submit -> prompt password field

hello.

Can someone help me to implement a password prompt after clicking on submit? I try to integrate this security layer, that only a person who knows the code (for exmaple "1234" can submit a change.

I have this so far:

[
    {
        "id": "dba2f963f07b8a2c",
        "type": "debug",
        "z": "191728c3ee9255a0",
        "name": "debug 283",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 210,
        "y": 1360,
        "wires": []
    },
    {
        "id": "56c39bc7d775cee5",
        "type": "change",
        "z": "191728c3ee9255a0",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "topic",
                "pt": "msg",
                "to": "topic[0]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic[1]",
                "pt": "msg",
                "to": "payload",
                "tot": "msg",
                "dc": true
            },
            {
                "t": "set",
                "p": "background",
                "pt": "msg",
                "to": "red",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 570,
        "y": 1460,
        "wires": [
            [
                "a37d74b2650693ab"
            ]
        ]
    },
    {
        "id": "a37d74b2650693ab",
        "type": "ui_button",
        "z": "191728c3ee9255a0",
        "name": "submit remote",
        "group": "83fd112e3229a323",
        "order": 2,
        "width": 2,
        "height": 1,
        "passthru": false,
        "label": "Submit",
        "tooltip": "",
        "color": "",
        "bgcolor": "{{background}}",
        "className": "",
        "icon": "",
        "payload": "submit",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 560,
        "y": 1400,
        "wires": [
            [
                "bd2fe2f48650c624",
                "11c59793e217158b"
            ]
        ]
    },
    {
        "id": "0185a74a24c023e4",
        "type": "rbe",
        "z": "191728c3ee9255a0",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "septopics": true,
        "property": "payload",
        "topi": "topic",
        "x": 790,
        "y": 1580,
        "wires": [
            [
                "a37d74b2650693ab",
                "4a9148d898273d95"
            ]
        ]
    },
    {
        "id": "bd2fe2f48650c624",
        "type": "change",
        "z": "191728c3ee9255a0",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "topic[1]",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "topic[0]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "background",
                "pt": "msg",
                "to": "transparent",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 830,
        "y": 1480,
        "wires": [
            [
                "0185a74a24c023e4"
            ]
        ]
    },
    {
        "id": "4a9148d898273d95",
        "type": "function",
        "z": "191728c3ee9255a0",
        "name": "Create Message",
        "func": "msg.payload = \"You selected \" + msg.payload\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 990,
        "y": 1540,
        "wires": [
            [
                "8c8840be4326444f"
            ]
        ]
    },
    {
        "id": "8c8840be4326444f",
        "type": "debug",
        "z": "191728c3ee9255a0",
        "name": "debug 285",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1190,
        "y": 1520,
        "wires": []
    },
    {
        "id": "cf7b206144781618",
        "type": "ui_dropdown",
        "z": "191728c3ee9255a0",
        "name": "",
        "label": "OPERATINGMODE1:",
        "tooltip": "Change operating mode",
        "place": "",
        "group": "83fd112e3229a323",
        "order": 1,
        "width": 4,
        "height": 1,
        "passthru": true,
        "multiple": false,
        "options": [
            {
                "label": "Manual",
                "value": 0,
                "type": "num"
            },
            {
                "label": "Pulse",
                "value": 1,
                "type": "num"
            },
            {
                "label": "Analog",
                "value": 2,
                "type": "num"
            },
            {
                "label": "Timer",
                "value": 3,
                "type": "num"
            },
            {
                "label": "Batch",
                "value": 4,
                "type": "num"
            }
        ],
        "payload": "",
        "topic": "[]",
        "topicType": "str",
        "className": "",
        "x": 120,
        "y": 1460,
        "wires": [
            [
                "dba2f963f07b8a2c",
                "8a3a6723ef7e91a3"
            ]
        ]
    },
    {
        "id": "8a3a6723ef7e91a3",
        "type": "change",
        "z": "191728c3ee9255a0",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "code",
                "pt": "global",
                "to": "1234",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 1460,
        "wires": [
            [
                "56c39bc7d775cee5"
            ]
        ]
    },
    {
        "id": "11c59793e217158b",
        "type": "debug",
        "z": "191728c3ee9255a0",
        "name": "debug 286",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 770,
        "y": 1380,
        "wires": []
    },
    {
        "id": "83fd112e3229a323",
        "type": "ui_group",
        "name": "CONTROL",
        "tab": "4ad3c40739cbf998",
        "order": 1,
        "disp": true,
        "width": "10",
        "collapse": false,
        "className": ""
    },
    {
        "id": "4ad3c40739cbf998",
        "type": "ui_tab",
        "name": "PUMP A",
        "icon": "dashboard",
        "order": 3,
        "disabled": false,
        "hidden": false
    }
]

Why after? To do that, you will need to prevent the submit button from doing its normal job and get the click event to run some front-end JavaScript to pop up a dialogue box with another form in it. Quite a lot of work for little reward?

You could, instead, add another field to your form. Then it would be a simple job of checking the returned message for the code.

However, remember that this approach is not "Secure". You will need TLS encryption on the connection (HTTPS) as an absolute minimum. Things like hashing the code before submission might be another step.

PS: Sorry, ran out of time yesterday and forgot to submit this so it is 24hrs late :slight_smile:

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