fix: race conditions, cookie logic, and the try again button (#833)

* fix(lib): fix race condition when rendering multiple challenge pages at once

Closes #832

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(web): make try again button work

Looks like the intent of this was "try the solution again". This fix
makes the client try the challenge again.

Signed-off-by: Xe Iaso <me@xeiaso.net>

* fix(web): don't block a user if they have an invalid challenge cookie

Signed-off-by: Xe Iaso <me@xeiaso.net>

* docs: update CHANGELOG

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso 2025-07-14 20:54:08 -04:00 committed by GitHub
parent 0fd4bb81b8
commit d28991ce8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 187 additions and 147 deletions

View file

@ -10,7 +10,7 @@ import (
templ base(title string, body templ.Component, impressum *config.Impressum, challenge any, ogTags map[string]string, localizer *localization.SimpleLocalizer) {
<!DOCTYPE html>
<html lang={localizer.GetLang()}>
<html lang={ localizer.GetLang() }>
<head>
<title>{ title }</title>
<link rel="stylesheet" href={ anubis.BasePrefix + xess.URL }/>
@ -122,11 +122,18 @@ templ index(localizer *localization.SimpleLocalizer) {
</div>
}
templ errorPage(message string, mail string, localizer *localization.SimpleLocalizer) {
script reload(redirect string) {
if (redirect === "") {
redirect = "/";
}
window.location = redirect;
}
templ errorPage(message, mail, redirect string, localizer *localization.SimpleLocalizer) {
<div class="centered-div">
<img id="image" alt="Sad Anubis" style="width:100%;max-width:256px;" src={ anubis.BasePrefix + "/.within.website/x/cmd/anubis/static/img/reject.webp?cacheBuster=" + anubis.Version }/>
<p>{ message }.</p>
<button onClick="window.location.reload();">{ localizer.T("try_again") }</button>
<button onClick={ reload(redirect) }>{ localizer.T("try_again") }</button>
if mail != "" {
<p>
<a href="/">{ localizer.T("go_home") }</a> { localizer.T("contact_webmaster") }