Mercurial > prosody-modules
diff mod_auth_oauth_external/mod_auth_oauth_external.lua @ 5440:82a14082be3f
mod_auth_oauth_external: Allow different username in PLAIN vs final JID
Mastodon for example having email addresses usernames in login, but a
different username in the service itself.
Thanks to @tcit@social.tcit.fr for the pointer to a usable validation
endpoint for Mastodon, allowing this to be tested.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 10 May 2023 13:52:31 +0200 |
parents | 721f79ac88d8 |
children | 7480dde4cd2e |
line wrap: on
line diff
--- a/mod_auth_oauth_external/mod_auth_oauth_external.lua Wed May 10 13:45:28 2023 +0200 +++ b/mod_auth_oauth_external/mod_auth_oauth_external.lua Wed May 10 13:52:31 2023 +0200 @@ -71,9 +71,12 @@ return false, nil; end local response = json.decode(ret.body); - if type(response) ~= "table" or (response[username_field]) ~= username then + if type(response) ~= "table" then + return false, nil, nil; + elseif type(response[username_field]) ~= "string" then return false, nil, nil; end + self.username = jid.escape(response[username_field]); self.token_info = response; return true, true; end