From dae38bbd838bd8fcc05cd2591338292923679c75 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 19 Nov 2025 12:39:06 -0500 Subject: [PATCH] login: Don't show an empty / undefined code of conduct. --- core/auth.html | 10 ++++++++-- src/httpd.login.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/auth.html b/core/auth.html index 71deaba9..1a1ed596 100644 --- a/core/auth.html +++ b/core/auth.html @@ -75,6 +75,10 @@ margin-bottom: 1em; padding: 1em; } + #code_of_conduct:has(>textarea:empty) { + display: none; + width: 100%; + }

Welcome.

@@ -126,8 +130,10 @@ There is currently no administrator. You will be made administrator.
-

Code of Conduct

- +
+

Code of Conduct

+ +
`; } diff --git a/src/httpd.login.c b/src/httpd.login.c index ca2a29fb..9e5a3582 100644 --- a/src/httpd.login.c +++ b/src/httpd.login.c @@ -352,7 +352,7 @@ static void _httpd_endpoint_login_work(tf_ssb_t* ssb, void* user_data) { JSValue settings_value = JS_ParseJSON(context, login->settings, strlen(login->settings), NULL); JSValue code_of_conduct_value = JS_GetPropertyStr(context, settings_value, "code_of_conduct"); - const char* code_of_conduct = JS_ToCString(context, code_of_conduct_value); + const char* code_of_conduct = JS_IsString(code_of_conduct_value) ? JS_ToCString(context, code_of_conduct_value) : NULL; const char* result = tf_strdup(code_of_conduct); JS_FreeCString(context, code_of_conduct); JS_FreeValue(context, code_of_conduct_value);