Skip to content

users.find_by_identifier searches the app's users with the secret key - #5

Merged
imit merged 1 commit into
mainfrom
sdk-fixes
Sep 28, 2026
Merged

imit merged 1 commit into
mainfrom
sdk-fixes

Conversation

@imit

@imit imit commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Mirrors the Python SDK change.

users.find_by_identifier

  • It now searches the app's users with the secret key (the user list, GET /v1/:app_id/users with q, limit=100, page) and keeps only an exact match:
    • the email in any case;
    • the phone number compared as digits (include the country code).
  • q is a loose search, so it can answer near-identical users; they don't count.
  • It follows next_page for up to 10 pages.
  • It returns nil when nobody by that identifier uses the app, and never creates a user.
  • A blank identifier (or a phone with no digits) makes no call.
  • Same signature. The result is the user as users.get shows it.
  • Unit tests: the fake API gets a loose user list that pages by 2. The tests cover an exact match on a later page, phones in any format, near misses, the page limit, and no call for a blank identifier.

Sessions

sessions.list and sessions.revoke work with the secret key alone, no user session needed. The docs, README and CHANGELOG say so.

Live suite

The examples that were pending on API behavior are normal examples again:

  • listing and revoking sessions;
  • a refreshed token verifying locally;
  • find_by_identifier answering nil for nobody (and making nobody).

A new example checks the exact match against the real, loose search, by email (in another case) and by phone (formatted differently).

Results:

  • bundle exec rake live against scute-api-v2 v23: 74 examples, 0 failures, 1 pending. The pending one is a skip: scute-ruby has no local decision engine for the policy snapshot.
  • Unit suite: 84 examples, 0 failures. RuboCop is clean.

After the run, the suite's app has no users, agents, properties or policy left, and its settings are back to their defaults.

find_by_identifier now uses the user list (GET /v1/:app_id/users, q=...)
with the secret key and keeps only an exact match: the email in any case,
or the phone compared as digits. It returns nil when nobody by that
identifier uses the app, never creates a user, makes no call for a blank
identifier, and follows the list's pages, up to 10 pages of 100.

sessions.list and sessions.revoke work with the app's secret key alone;
the docs and README say so.

The live suite's examples for these (listing and revoking sessions, a
refreshed token verifying locally, find_by_identifier for nobody) are
normal examples again, and a new one checks the exact match by email and
by phone: 74 examples, 0 failures, 1 pending against scute-api-v2 v23.
@imit
imit merged commit 4fa0151 into main Sep 28, 2026
3 checks passed
@imit
imit deleted the sdk-fixes branch September 28, 2026 16:17
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.

1 participant