Browse Source

Make authenticated username available to scripts. (#100)

See node_info.lua for usage example.
Marcos 3 years ago
parent
commit
7b25c727fe
2 changed files with 2 additions and 0 deletions
  1. 1 0
      http/node_info.lua
  2. 1 0
      httpserver.lua

+ 1 - 0
http/node_info.lua

@@ -28,5 +28,6 @@ return function (connection, req, args)
    sendAttr(connection, 'Station IP address'    , ip)
    sendAttr(connection, 'Station subnet mask'   , subnetMask)
    sendAttr(connection, 'MAC address'           , wifi.sta.getmac())
+   sendAttr(connection, 'Auth user'             , req.user)
    connection:send('</ul></body></html>')
 end

+ 1 - 0
httpserver.lua

@@ -125,6 +125,7 @@ return function (port)
             end
 
             if user and req.methodIsValid and (req.method == "GET" or req.method == "POST" or req.method == "PUT") then
+               req.user = user
                handleRequest(connection, req, handleError)
             else
                local args = {}