# HG changeset patch # User Kim Alvefur # Date 1582840736 -3600 # Node ID dea6bea2ddd354c6b3093e8e1800f79c131ff1ce # Parent 3e19c25ff93ecbd766eef93ebb373f2ac6703eb5 mod_http_oauth2: Refactor re-joining of JID out of token constructor Preparing for resource-bound tokens and handling of Components diff -r 3e19c25ff93e -r dea6bea2ddd3 mod_http_oauth2/mod_http_oauth2.lua --- a/mod_http_oauth2/mod_http_oauth2.lua Thu Feb 27 00:59:17 2020 +0100 +++ b/mod_http_oauth2/mod_http_oauth2.lua Thu Feb 27 22:58:56 2020 +0100 @@ -16,8 +16,7 @@ }); end -local function new_access_token(username, host, scope, ttl) - local token_jid = jid.join(username, host); +local function new_access_token(token_jid, scope, ttl) local token = tokens.create_jid_token(token_jid, token_jid, scope, ttl); return { token_type = "bearer"; @@ -40,7 +39,8 @@ return oauth_error("invalid_request", "invalid JID"); end if usermanager.test_password(request_username, request_host, request_password) then - return json.encode(new_access_token(request_username, request_host, nil, nil)); + local granted_jid = jid.join(request_username, request_host); + return json.encode(new_access_token(granted_jid, request_host, nil, nil)); end return oauth_error("invalid_grant", "incorrect credentials"); end