From ff83e9abceecb663129947be711097b231c164fc Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Mon, 13 May 2024 14:00:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Better=20response=20when=20not?= =?UTF-8?q?=20eligible=20to=20vote?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/main.go | 2 +- tmpl/not_eligible.html | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tmpl/not_eligible.html diff --git a/http/main.go b/http/main.go index 6d349a5..8fbcc2e 100644 --- a/http/main.go +++ b/http/main.go @@ -137,7 +137,7 @@ func handleShowVoting(ctx echo.Context) error { } if v.Deadline().After(time.Now().UTC()) { if !eligible(ctx.Request().Header.Get("X-Remote-User"), v.Electors()) { - return ctx.String(http.StatusForbidden, "") + return ctx.Render(http.StatusOK, "not_eligible", nil) } } return ctx.Render(http.StatusOK, "voting", map[string]interface{}{ diff --git a/tmpl/not_eligible.html b/tmpl/not_eligible.html new file mode 100644 index 0000000..9ef60b7 --- /dev/null +++ b/tmpl/not_eligible.html @@ -0,0 +1,19 @@ +{{ define "not_eligible" }} +{{ template "head" . }} +
+
+
+

+ Not eligible! +

+

+ Sorry, you are not eligible to vote +

+
+ +
+
+
+
+{{ template "tail" . }} +{{ end }}