All jobs

Review Pull Requests That Change Passport.js Login Code

Yes. An agent checks out the branch, runs your Passport tests, reads the account-linking and token logic the diff touches and posts a review with evidence.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent checks out the pull request's branch in its own sandbox and reads the code around the diff, not just the diff. In sahat/hackathon-starter, everything about sign-in lives in config/passport.js, about 900 lines that register a local strategy and more than ten OAuth providers (GitHub, Google, Facebook, X, LinkedIn, Microsoft, Twitch, Tumblr, Steam, QuickBooks, Discord), each under a provider key that is also the kind stored in User.tokens. The repository's own AGENTS.md maps where each provider appears: the routes in app.js, passport.js, config/token-revocation.js, which is driven by the exported providerRevocationConfig, and the account views. It also says which providers have a refresh.use(...) call for passport-oauth2-refresh: google, linkedin, microsoft, twitch, quickbooks and discord.

With that map it checks the parts of a change that tests rarely catch. handleAuthLogin decides whether an OAuth sign-in links to the signed-in user, signs in an existing user by provider id, or creates an account. It refuses to create one when another account already has the provider's email, and tells the person to sign in by email and link from their profile instead; a change that relaxes that check would let anyone who controls an email at a provider take over the matching local account. Queries use $eq ({ [providerName]: { $eq: providerProfile.id } }), so the agent flags a new query that passes a value from a profile or request straight into a filter. Emails go through validator.normalizeEmail with gmail_remove_dots: false, so a new code path that skips it can create a second account for the same address.

For token code it reads isAuthorized, which takes the provider from req.path, refreshes an access token that expired more than a minute ago when a refresh token exists, and otherwise redirects to /auth/<provider>; and saveOAuth2UserTokens, which converts expires_in seconds into dates and keeps an existing refresh token when the provider sends none. A pull request that adds a provider is checked for all of its pieces: passport.use, routes in app.js, a refresh.use if it issues refresh tokens, a providerRevocationConfig entry, and the account view. One that removes a provider is checked for the same pieces left behind.

Then it runs what CI runs. package.json requires Node 24.18 or newer; the agent runs npm install, npm run lint-check (ESLint and prettier --check), and npm run test, which runs Mocha under c8; the tests that need a database start mongodb-memory-server, so no MongoDB has to be installed. test/passport.test.js covers isAuthenticated, serialization, the local strategy, the seven isAuthorized scenarios and _saveOAuth2UserTokens; the agent says whether the pull request's change is covered by one of them, and if not, which case is missing.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Review this pull request. Read AGENTS.md, config/passport.js, config/token-revocation.js, the auth routes in app.js, models/User.js and test/passport.test.js before the diff. Check account linking in handleAuthLogin: an OAuth sign-in must never attach to or create an account whose email belongs to another user. Check that every MongoDB filter built from a profile or request uses $eq, that emails are normalized the same way as elsewhere, and that token expiry and refresh logic in isAuthorized and saveOAuth2UserTokens still holds. For a provider added or removed, check passport.use, the app.js routes, refresh.use, providerRevocationConfig and the account views together. Run npm install, npm run lint-check and npm run test, and say which existing test covers the change or which case is missing. Post one GitHub review that cites file and line for every finding, separates blocking issues from suggestions, and includes the test and lint results. Do not push commits.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app/pull/1"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

What comes back is one review on the pull request. Each finding cites a file and line and says why it matters: an account-linking path that no longer checks the email, a filter without $eq, a provider added without its revocation entry, a refresh call for a provider that issues no refresh tokens. Blocking issues are separated from suggestions, and the review ends with the npm run lint-check and npm run test results and which test in test/passport.test.js covers the change.

The agent pushes nothing. The session keeps the transcript of every command with its output, and GET /o/{org}/sessions/{id} returns the agent's final answer as result, so a summary of the review can be posted somewhere else or kept with the pull request's record.

The person who merges still decides. The review is evidence for that decision: what was run, what passed, and which lines of the change were read against which part of the login flow.

Run it on every pull request that touches auth

Create an automation in the Project with a github trigger on pull_request.opened and pull_request.synchronize, branch_patterns set to your default branch, and this prompt. Each fire adds the pull request after the prompt, so every push to it gets its own sandbox and its own review. Mark the automation read_only so its runs can comment and never push. Only work by an owner, member or collaborator fires it; pull requests from forks do not.

To review only pull requests that change sign-in code, filter on your own server instead: receive GitHub's pull_request webhook, check whether the changed files include config/passport.js, config/token-revocation.js or models/User.js, and only then send this body to POST /o/{org}/sessions with the pull request URL in resources and a request_id that is a UUID v5 of the head commit SHA.

The use case this job follows, with its automation and trigger: Review every pull request.

Why run it on Rush?

Auth changes deserve a reviewer who reads the whole flow, and that takes time a busy maintainer rarely has. The agent reads handleAuthLogin, isAuthorized and the revocation config end to end on every pull request and runs the full Mocha suite in its own sandbox, with an in-memory MongoDB and no OAuth secrets, so nothing from a contributor's branch runs on a maintainer's machine.

Each claim in the review comes with its evidence: the file and line, and the lint and test output in the transcript. A reviewer can check any finding against the code in a minute instead of re-deriving the login flow.

Frequently asked questions

Does it need our OAuth client secrets?

No. The tests in test/passport.test.js stub the user model and refresh.requestNewAccessToken with sinon, and the review reads code rather than signing in. No secret is put in the sandbox for a review.

Will it push fixes to the pull request?

No. The prompt says not to push, and an automation marked read_only cannot. If you want a fix, ask in a follow-up to the same session, and that run can push a commit.

Does it run the Playwright end-to-end tests?

Not by default. Those exercise the API examples, not sign-in, and replay recorded responses. Add npm run test:e2e:replay to input if a pull request touches the pages they cover.

Our app uses passport-local and one OAuth provider. Is this still useful?

Yes. The checks are about the same places in any Passport app: how an OAuth profile is matched to an account, how queries are built from profile data, and how tokens are stored and refreshed. Name your files in input if they live somewhere other than config/passport.js.

More Passport.js jobs

The same job on other stacks

Keep reading