commit d925b61c660e64e8445d519c5ea3fa4ea6e4f044
parent 9e1ceeba2fb27204e0970de395a5b3bc1d7de9e5
Author: Silas Brack <silasbrack@gmail.com>
Date: Sun, 7 Jun 2026 21:50:05 +0200
fix: replace unwrap() panic in reply form with proper error
The show_reply_form handler called unwrap() on cookie tokens
which would panic if the user wasn't logged in. Now returns
a proper Unauthorized error instead.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/handlers/comment.rs b/src/handlers/comment.rs
@@ -114,7 +114,8 @@ pub async fn show_reply_form(
));
}
- let tokens = get_tokens_from_cookies(&jar).unwrap();
+ let tokens = get_tokens_from_cookies(&jar)
+ .ok_or_else(|| AppError::Unauthorized("Login required".to_string()))?;
let client = trailbase::client_with_tokens(&state.trailbase_url, &tokens)?;
// Get the parent comment to show what we're replying to