# HG changeset patch # User Kim Alvefur # Date 1683719551 -7200 # Node ID 82a14082be3f18faca9efa15f118161aa59d9a12 # Parent 721f79ac88d8e6d4ac5cd31b571570e886fcf634 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. diff -r 721f79ac88d8 -r 82a14082be3f mod_auth_oauth_external/mod_auth_oauth_external.lua --- 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