Skip to content

Skip login captcha when any idb_* cookie exists, not just idb_$z#133

Merged
ideav merged 3 commits intomainfrom
issue-132-4c40203b8a9c
May 1, 2026
Merged

Skip login captcha when any idb_* cookie exists, not just idb_$z#133
ideav merged 3 commits intomainfrom
issue-132-4c40203b8a9c

Conversation

@konard
Copy link
Copy Markdown
Collaborator

@konard konard commented May 1, 2026

Summary

  • index.php login guard now skips verifyCaptcha() when the user holds any idb_* cookie, not just idb_$z (the current-database token).
  • Added tests/index-captcha-skip.test.mjs to verify this behavior.

Problem

PR #131 fixed captcha skipping only for users who already have a token for the current database (idb_$z). But a user may be authenticated to a different database and carry an idb_<other> cookie. In that case the server still demanded a captcha even though the client already hid the widget — making the form unsubmittable.

How to reproduce the issue

  1. Log in to database A — acquires idb_A cookie.
  2. Navigate to the login page for database B.
  3. The client hides the captcha widget (correct — any idb_* cookie is found).
  4. Submit the login form → server rejects it with a captcha error (bug — server only checked idb_$z i.e. idb_B).

What changed

index.php login guard (line 8001):

// Before (PR #131)
if(isset($_POST["smart-token"]) && !isset($_COOKIE["idb_$z"]) && !verifyCaptcha($_POST["smart-token"])){

// After (this PR)
$hasAnyIdbCookie = (bool)preg_grep('/^idb_/', array_keys($_COOKIE));
if(isset($_POST["smart-token"]) && !$hasAnyIdbCookie && !verifyCaptcha($_POST["smart-token"])){

This mirrors the client-side hasIdbCookie() check already in src/pages/Home.tsx.

Test plan

  • npm test — all 9 tests pass
  • New test index.php skips SmartCaptcha verification for users with any idb_* cookie on login passes

Fixes #132

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #132
@konard konard self-assigned this May 1, 2026
Fixes #132: a user may hold tokens for databases other than the current
one. Using preg_grep on array_keys($_COOKIE) detects any idb_* cookie
the same way the client-side hasIdbCookie() helper already does.
@konard konard changed the title [WIP] https://github.com/ideav/backlogram/pull/131 Опять не так - токен любой БД может быть, не только текущей Skip login captcha when any idb_* cookie exists, not just idb_$z May 1, 2026
@konard konard marked this pull request as ready for review May 1, 2026 07:25
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 1, 2026

Working session summary

Done. Here's what was fixed and why:

Root cause: PR #131 introduced captcha skipping in index.php but checked only $_COOKIE["idb_$z"] — the token for the current database. The client-side (Home.tsx) correctly checks for any idb_* cookie, so when a user was authenticated to a different database they'd see no captcha widget but the server would still reject the form with a captcha error.

Fix: index.php:8001 now uses preg_grep('/^idb_/', array_keys($_COOKIE)) to detect any idb_* cookie, exactly mirroring the client-side hasIdbCookie() logic. All 9 tests pass.

PR: #133


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 1, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.568802

📊 Context and tokens usage:

  • peak request: 26.4K / 1M (3%) input tokens, 5.0K / 64K (8%) output tokens

Total: (25 new + 47.1K cache writes + 1.1M cache reads) input tokens, 5.0K output tokens, $0.568802 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1342KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 1, 2026

✅ Ready to merge

This pull request is now ready to be merged:

  • No CI/CD checks are configured for this repository
  • No merge conflicts
  • No pending changes

Monitored by hive-mind with --auto-restart-until-mergeable flag

@ideav ideav merged commit 2b556c1 into main May 1, 2026
@ideav ideav deleted the issue-132-4c40203b8a9c branch May 1, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

https://github.com/ideav/backlogram/pull/131 Опять не так - токен любой БД может быть, не только текущей

2 participants