# HG changeset patch # User Kim Alvefur # Date 1689764747 -7200 # Node ID 1893ae742f66a89ab4369147e6cd33aa6fa1092a # Parent ad9b8f659c96faa57a7f75f4890be14906b513dc mod_http_oauth2: Show errors on device flow user code entry page If the user enters the code incorrectly, having to click back to try again is no fun. Instead, show the error and the code entry form again. diff -r ad9b8f659c96 -r 1893ae742f66 mod_http_oauth2/html/device.html --- a/mod_http_oauth2/html/device.html Wed Jul 19 12:58:04 2023 +0200 +++ b/mod_http_oauth2/html/device.html Wed Jul 19 13:05:47 2023 +0200 @@ -11,6 +11,9 @@

{site_name}

Device Authorization + {error&
+

{error.text}

+
} {client&

Authorization completed. You can go back to {client.client_name}.

} diff -r ad9b8f659c96 -r 1893ae742f66 mod_http_oauth2/mod_http_oauth2.lua --- a/mod_http_oauth2/mod_http_oauth2.lua Wed Jul 19 12:58:04 2023 +0200 +++ b/mod_http_oauth2/mod_http_oauth2.lua Wed Jul 19 13:05:47 2023 +0200 @@ -1011,7 +1011,10 @@ local device_info = codes:get("user_code:" .. params.user_code); if not device_info or code_expired(device_info) or not codes:set("user_code:" .. params.user_code, nil) then - return render_error(oauth_error("expired_token", "Incorrect or expired code")); + return render_page(templates.device, { + client = false; + error = oauth_error("expired_token", "Incorrect or expired code"); + }); end return {