Skip to content

Commit cd14a1a

Browse files
Fix email verification: codes were silently failing to save
Root cause: /var/lib/octopoda/ directory didn't exist on the server, _save_verify_codes() silently swallowed the error (bare except: pass), so codes were emailed but never persisted. Every verify attempt failed with "Invalid or expired code" — causing users to spam resend. Fixes: - Auto-create directory with os.makedirs() before writing - Log errors instead of silently swallowing them - Increase code TTL from 10 → 30 minutes (less pressure on users) - Update email template to say 30 minutes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2c43814 commit cd14a1a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

synrix_runtime/api/cloud_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def _validate_name(name: str, field: str):
526526
fcntl = None # Not available on Windows; file locking skipped
527527
# json imported at top of file
528528

529-
_VERIFY_CODE_TTL = 600 # 10 minutes
529+
_VERIFY_CODE_TTL = 1800 # 30 minutes
530530
_MAX_VERIFY_ATTEMPTS = 5
531531
_VERIFY_FILE = os.environ.get("OCTOPODA_VERIFY_FILE", "/var/lib/octopoda/verification_codes.json")
532532

@@ -544,14 +544,15 @@ def _load_verify_codes() -> dict:
544544

545545
def _save_verify_codes(codes: dict):
546546
try:
547+
os.makedirs(os.path.dirname(_VERIFY_FILE), exist_ok=True)
547548
with open(_VERIFY_FILE, "w") as f:
548549
if fcntl:
549550
fcntl.flock(f, fcntl.LOCK_EX)
550551
json.dump(codes, f)
551552
if fcntl:
552553
fcntl.flock(f, fcntl.LOCK_UN)
553-
except Exception:
554-
pass
554+
except Exception as e:
555+
logger.error("Failed to save verification codes to %s: %s", _VERIFY_FILE, e)
555556

556557
def _generate_verification_code(email: str) -> str:
557558
code = str(_secrets.randbelow(900000) + 100000)
@@ -621,7 +622,7 @@ def _send_verification_email(email: str, first_name: str, code: str):
621622
{code}
622623
</div>
623624
<p style="color: #999; font-size: 12px; margin: 24px 0 0;">
624-
This code expires in 10 minutes.
625+
This code expires in 30 minutes.
625626
</p>
626627
</div>
627628
<p style="color: #999; font-size: 12px; text-align: center; margin: 24px 0 0;">
@@ -670,7 +671,7 @@ def _send_password_reset_email(email: str, first_name: str, code: str):
670671
{code}
671672
</div>
672673
<p style="color: #999; font-size: 12px; margin: 24px 0 0;">
673-
This code expires in 10 minutes.
674+
This code expires in 30 minutes.
674675
</p>
675676
</div>
676677
<p style="color: #999; font-size: 12px; text-align: center; margin: 24px 0 0;">

0 commit comments

Comments
 (0)