Fires event before setting username, allows listeners to override it.
This is a hook to override the username that will be used when authenticating token users (which are using anonymous login with auto-generated username).
This commit is contained in:
parent
599d84a889
commit
cc79b073f0
|
@ -58,7 +58,18 @@ end
|
|||
function provider.get_sasl_handler(session)
|
||||
|
||||
local function get_username_from_token(self, message)
|
||||
return token_util:process_and_verify_token(session);
|
||||
local res = token_util:process_and_verify_token(session);
|
||||
|
||||
local customUsername
|
||||
= prosody.events.fire_event("pre-jitsi-authentication", session);
|
||||
|
||||
if (customUsername) then
|
||||
self.username = customUsername;
|
||||
else
|
||||
self.username = message;
|
||||
end
|
||||
|
||||
return res;
|
||||
end
|
||||
|
||||
return new_sasl(host, { anonymous = get_username_from_token });
|
||||
|
@ -73,8 +84,6 @@ local function anonymous(self, message)
|
|||
-- This calls the handler created in 'provider.get_sasl_handler(session)'
|
||||
local result, err, msg = self.profile.anonymous(self, username, self.realm);
|
||||
|
||||
self.username = username;
|
||||
|
||||
if result == true then
|
||||
return "success";
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue