commit 6d1aea792c05fb48819dcadf3a912748819aab93
parent fac5c193cb0faed029c049eaa4538f8bf9269144
Author: Silas Brack <silasbrack@gmail.com>
Date: Sun, 7 Jun 2026 14:28:11 +0200
fix: handle 303 redirect from trailbase registration
Trailbase returns 303 on successful registration. Treat redirects
as success and show email verification message if login fails.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/trailbase.rs b/src/trailbase.rs
@@ -664,14 +664,19 @@ pub async fn register(client: &Client, email: &str, password: &str) -> Result<St
.await
.map_err(|e| ClientError::Auth(format!("HTTP error: {}", e)))?;
- if !response.status().is_success() {
- let status = response.status();
+ let status = response.status();
+ if !status.is_success() && !status.is_redirection() {
let body = response.text().await.unwrap_or_default();
return Err(ClientError::Auth(format!("Registration failed ({}): {}", status, body)));
}
- // After registration, log in to get tokens
- client.login(email, password).await?;
+ // If redirected (303), registration succeeded but email verification may be required.
+ // Try to log in — if email verification is enabled, this may fail.
+ if let Err(_) = client.login(email, password).await {
+ return Err(ClientError::Auth(
+ "Registration successful! Please check your email to verify your account.".into(),
+ ));
+ }
let tokens = client.tokens().ok_or_else(|| {
ClientError::Auth("No tokens after registration".into())