🩹 Better response when not eligible to vote

This commit is contained in:
Brian Wiborg 2024-05-13 14:00:05 +02:00
parent 8f3a5b35c8
commit ff83e9abce
No known key found for this signature in database
GPG Key ID: BE53FA9286B719D6
2 changed files with 20 additions and 1 deletions

View File

@ -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{}{

19
tmpl/not_eligible.html Normal file
View File

@ -0,0 +1,19 @@
{{ define "not_eligible" }}
{{ template "head" . }}
<div class="flex flex-col justify-center align-center items-center h-screen bg-slate-900 p-2">
<div class="w-full md:w-3/4 lg:w-1/2 xl:w-1/3 border rounded-lg p-2 sm:p-6 md:p-8 bg-slate-800 border-purple-900 text-white">
<div class="relative sm:rounded-lg">
<h1 class="text-center text-4xl text-white pb-2">
Not eligible!
</h1>
<p class="p-4 text-gray-400 text-center">
Sorry, you are not eligible to vote
</p>
<form action="/v" method="GET">
<button type="submit" class="w-full hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center bg-purple-600 hover:bg-purple-700 focus:ring-blue-800 text-white hover:text-yellow-200 text-xl">Go back</button>
</form>
</div>
</div>
</div>
{{ template "tail" . }}
{{ end }}