mod_http_oauth2: Fix returning errors from response handlers
authorKim Alvefur <zash@zash.se>
Thu, 18 May 2023 12:57:23 +0200
changeset 5472 14b5446e22e1
parent 5471 1c78a97a1091
child 5473 03f393d572fe
mod_http_oauth2: Fix returning errors from response handlers This would either redirect the user back to the client along with the error code, or show the error HTML template. Previously this would just show some JSON to the user.
mod_http_oauth2/mod_http_oauth2.lua
--- a/mod_http_oauth2/mod_http_oauth2.lua	Wed May 17 19:40:27 2023 +0200
+++ b/mod_http_oauth2/mod_http_oauth2.lua	Thu May 18 12:57:23 2023 +0200
@@ -754,7 +754,11 @@
 	if not response_handler then
 		return error_response(request, oauth_error("unsupported_response_type"));
 	end
-	return response_handler(client, params, user_jid, id_token);
+	local ret = response_handler(client, params, user_jid, id_token);
+	if errors.is_err(ret) then
+		return error_response(request, ret);
+	end
+	return ret;
 end
 
 local function handle_revocation_request(event)