Merge pull request #7679 from jitsi/mod-token-update
fix: Updates docs and verification to halt joining process.
This commit is contained in:
commit
53d485b397
|
@ -40,6 +40,7 @@ local function load_config()
|
||||||
end
|
end
|
||||||
load_config();
|
load_config();
|
||||||
|
|
||||||
|
-- verify user and whether he is allowed to join a room based on the token information
|
||||||
local function verify_user(session, stanza)
|
local function verify_user(session, stanza)
|
||||||
log("debug", "Session token: %s, session room: %s",
|
log("debug", "Session token: %s, session room: %s",
|
||||||
tostring(session.auth_token),
|
tostring(session.auth_token),
|
||||||
|
@ -49,7 +50,7 @@ local function verify_user(session, stanza)
|
||||||
local user_jid = stanza.attr.from;
|
local user_jid = stanza.attr.from;
|
||||||
if is_admin(user_jid) then
|
if is_admin(user_jid) then
|
||||||
log("debug", "Token not required from admin user: %s", user_jid);
|
log("debug", "Token not required from admin user: %s", user_jid);
|
||||||
return nil;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
log("debug",
|
log("debug",
|
||||||
|
@ -64,18 +65,23 @@ local function verify_user(session, stanza)
|
||||||
end
|
end
|
||||||
log("debug",
|
log("debug",
|
||||||
"allowed: %s to enter/create room: %s", user_jid, stanza.attr.to);
|
"allowed: %s to enter/create room: %s", user_jid, stanza.attr.to);
|
||||||
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
module:hook("muc-room-pre-create", function(event)
|
module:hook("muc-room-pre-create", function(event)
|
||||||
local origin, stanza = event.origin, event.stanza;
|
local origin, stanza = event.origin, event.stanza;
|
||||||
log("debug", "pre create: %s %s", tostring(origin), tostring(stanza));
|
log("debug", "pre create: %s %s", tostring(origin), tostring(stanza));
|
||||||
return verify_user(origin, stanza);
|
if not verify_user(origin, stanza) then
|
||||||
|
return true; -- Returning any value other than nil will halt processing of the event
|
||||||
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
module:hook("muc-occupant-pre-join", function(event)
|
module:hook("muc-occupant-pre-join", function(event)
|
||||||
local origin, room, stanza = event.origin, event.room, event.stanza;
|
local origin, room, stanza = event.origin, event.room, event.stanza;
|
||||||
log("debug", "pre join: %s %s", tostring(room), tostring(stanza));
|
log("debug", "pre join: %s %s", tostring(room), tostring(stanza));
|
||||||
return verify_user(origin, stanza);
|
if not verify_user(origin, stanza) then
|
||||||
|
return true; -- Returning any value other than nil will halt processing of the event
|
||||||
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
for event_name, method in pairs {
|
for event_name, method in pairs {
|
||||||
|
|
Loading…
Reference in New Issue