changeset 5468:14b5446e22e1

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.
author Kim Alvefur <zash@zash.se>
date Thu, 18 May 2023 12:57:23 +0200
parents 1c78a97a1091
children 03f393d572fe
files mod_http_oauth2/mod_http_oauth2.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)