From 7b25c727fe11860b5d105872360c0f9623c0e9a7 Mon Sep 17 00:00:00 2001 From: Marcos Date: Sun, 2 Jul 2017 21:44:26 -0500 Subject: [PATCH] Make authenticated username available to scripts. (#100) See node_info.lua for usage example. --- http/node_info.lua | 1 + httpserver.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/http/node_info.lua b/http/node_info.lua index e143ca2..0adec13 100644 --- a/http/node_info.lua +++ b/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('') end diff --git a/httpserver.lua b/httpserver.lua index 18cba4b..a244335 100644 --- a/httpserver.lua +++ b/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 = {}