simple-web-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 484d607180858889f907c6efdf08cb7b08714283
parent 55c3aa1b5600a54909135ea1a91077d72041b626
Author: Silas Brack <silasbrack@gmail.com>
Date:   Sun,  7 Jun 2026 17:55:25 +0200

fix: convert URL-safe base64 user_id to standard base64

JWT uses URL-safe base64 (-/_) but trailbase stores user IDs
in standard base64 (+/). This mismatch caused vote lookups
to never match, so voted state wasn't shown on page load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Diffstat:
Msrc/trailbase.rs | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/trailbase.rs b/src/trailbase.rs @@ -47,7 +47,10 @@ pub fn extract_user_id_from_token(auth_token: &str) -> Option<String> { // Parse as JSON and extract "sub" claim let json: serde_json::Value = serde_json::from_str(&payload_str).ok()?; - json.get("sub").and_then(|v| v.as_str()).map(|s| s.to_string()) + // Convert URL-safe base64 to standard base64 to match trailbase's format + json.get("sub").and_then(|v| v.as_str()).map(|s| { + s.replace('-', "+").replace('_', "/") + }) } /// URL-safe base64 decode (handles missing padding)