grim/prosody_mod_auth_jetbrains_hub

Parents 0636130ba12b
Children d3192c27e286
User table.identifier instead of table["identifier"] when identifer is a valid identifier
--- a/mod_auth_jetbrains_hub.lua Sun Nov 03 04:01:02 2019 -0600
+++ b/mod_auth_jetbrains_hub.lua Sun Nov 03 04:05:36 2019 -0600
@@ -126,10 +126,10 @@
local resp = http_request(hub_url .. "/api/rest/users", headers, body)
- if resp["code"] == 200 then
+ if resp.code == 200 then
local json_payload = json_decode(response.body);
- if json_payload["total"] ~= 1 then
+ if json_payload.total ~= 1 then
return nil, "Permission denied";
end
@@ -150,18 +150,18 @@
}
local resp = http_request(hub_url.."/api/rest/oauth2/token", headers, body);
- if resp["code"] >= 200 and resp["code"] <= 299 then
+ if resp.code >= 200 and resp.code <= 299 then
module:log("debug", "HTTP auth provider confirmed valid password");
if #hub_groups > 0 then
- local json_payload = json_decode(resp["content"]);
+ local json_payload = json_decode(resp.content);
- return async_group_check(username, json_payload["access_token"])
+ return async_group_check(username, json_payload.access_token)
end
return true;
else
- module:log("debug", "HTTP auth provider returned status code %d", resp["code"]);
+ module:log("debug", "HTTP auth provider returned status code %d", resp.code);
end
return nil, "Auth failed. Invalid username or password.";