{
  "meta": {
    "$_POST": [
      {
        "type": "text",
        "name": "email"
      },
      {
        "type": "text",
        "name": "department"
      }
    ]
  },
  "exec": {
    "steps": [
      {
        "name": "strpwd",
        "module": "core",
        "action": "setvalue",
        "options": {
          "key": "g_strpwd",
          "value": "P@$$w0rd"
        },
        "meta": [],
        "output": true,
        "outputType": "text"
      },
      {
        "name": "hash",
        "module": "crypto",
        "action": "passwordHash",
        "options": {
          "password": "{{strpwd}}"
        },
        "outputType": "text"
      },
      {
        "name": "regcode",
        "module": "core",
        "action": "setvalue",
        "options": {
          "key": "g_regcode",
          "value": "{{UUID}}"
        },
        "meta": [],
        "outputType": "text"
      },
      {
        "name": "insert",
        "module": "dbupdater",
        "action": "insert",
        "options": {
          "connection": "authdb",
          "sql": {
            "type": "insert",
            "values": [
              {
                "table": "users",
                "column": "email",
                "type": "text",
                "value": "{{$_POST.email}}"
              },
              {
                "table": "users",
                "column": "pwd",
                "type": "text",
                "value": "{{hash}}"
              },
              {
                "table": "users",
                "column": "regcode",
                "type": "text",
                "value": "{{regcode}}"
              }
            ],
            "table": "users",
            "returning": "id",
            "query": "insert into `users` (`email`, `pwd`, `regcode`) values (?, ?, ?) returning `id`",
            "params": [
              {
                "name": ":P1",
                "type": "expression",
                "value": "{{$_POST.email}}",
                "test": ""
              },
              {
                "name": ":P2",
                "type": "expression",
                "value": "{{hash}}",
                "test": ""
              },
              {
                "name": ":P3",
                "type": "expression",
                "value": "{{regcode}}",
                "test": ""
              }
            ]
          }
        },
        "meta": [
          {
            "name": "identity",
            "type": "text"
          },
          {
            "name": "affected",
            "type": "number"
          }
        ],
        "output": true
      },
      {
        "name": "insert1",
        "module": "dbupdater",
        "action": "insert",
        "options": {
          "connection": "authdb",
          "sql": {
            "type": "insert",
            "values": [
              {
                "table": "xuserrole",
                "column": "userid",
                "type": "number",
                "value": "{{insert.identity}}"
              },
              {
                "table": "xuserrole",
                "column": "roleid",
                "type": "number",
                "value": "{{$_POST.department}}"
              }
            ],
            "table": "xuserrole",
            "returning": "id",
            "query": "insert into `xuserrole` (`roleid`, `userid`) values (?, ?)",
            "params": [
              {
                "name": ":P1",
                "type": "expression",
                "value": "{{insert.identity}}",
                "test": ""
              },
              {
                "name": ":P2",
                "type": "expression",
                "value": "{{$_POST.department}}",
                "test": ""
              }
            ]
          }
        },
        "meta": [
          {
            "name": "identity",
            "type": "text"
          },
          {
            "name": "affected",
            "type": "number"
          }
        ]
      },
      {
        "name": "insert2",
        "module": "dbupdater",
        "action": "insert",
        "options": {
          "connection": "authdb",
          "sql": {
            "type": "insert",
            "values": [
              {
                "table": "xuserrole",
                "column": "userid",
                "type": "number",
                "value": "{{insert.identity}}"
              },
              {
                "table": "xuserrole",
                "column": "roleid",
                "type": "number",
                "value": "4"
              }
            ],
            "table": "xuserrole",
            "returning": "id",
            "query": "insert into `xuserrole` (`roleid`, `userid`) values (?, ?)",
            "params": [
              {
                "name": ":P1",
                "type": "expression",
                "value": "{{insert.identity}}",
                "test": ""
              }
            ]
          }
        },
        "meta": [
          {
            "name": "identity",
            "type": "text"
          },
          {
            "name": "affected",
            "type": "number"
          }
        ]
      },
      {
        "name": "",
        "module": "mail",
        "action": "send",
        "options": {
          "instance": "mail",
          "subject": "Validation Code",
          "fromName": "RPM Access",
          "fromEmail": "no-reply@access2.prelub.com",
          "toName": "New User",
          "toEmail": "{{$_POST.email}}",
          "body": "<p>\nHere are your credentials to login for the first time and your registration code to validate your account.\nYour username is: {{$_POST.email}}\nYour password is: P@$$w0rd\nYour validation code is: {{regcode}}\n</p><Br/>\n<p>Click <a href='http://access2.prelub.com'>here</a> to be directed to the website.\n  Then click the account menu and login.\n  Once you login you will be prompted for the validation code.\n</p>\n\n\n\n",
          "contentType": "html"
        }
      }
    ]
  },
  "usedModules": {
    "argon2": "^0.30.2"
  }
}