Repository navigation
fix: migrate authentication to id.factorialhr.com - #344
Merged
Merged
Conversation
Factorial moved the login form from api.factorialhr.com/es/users/sign_in
to a SPA hosted on id.factorialhr.com. The legacy form is gone (302s to
the new SPA), so the old two-step HTML+form-encoded flow no longer
produces a _factorial_session_v2 cookie.
The new flow is a single JSON POST to
/api/auth/challenges/first_factor with {email, password}. On success
it sets a _factorial_id cookie (JWT) on .factorialhr.com, which is
still accepted by api.factorialhr.com for the rest of the endpoints
the CLI uses (no other code changes needed).
- POST JSON instead of form-encoded; no more authenticity_token scrape
- Read the new _factorial_id cookie from set-cookie
- authenticatedHeadersWith now emits cookie: _factorial_id=...
- Detect 422 invalid_credentials and rethrow as "Invalid email or password"
- Update integration test cookie shape to the JWT format
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api.factorialhr.com/es/users/sign_into a SPA onid.factorialhr.com; the legacy endpoint now 302s away and no longer sets a_factorial_session_v2cookie, so the CLI's login was broken.FactorialAuthenticatoragainst the new endpoint: a single JSONPOST https://id.factorialhr.com/api/auth/challenges/first_factorwith{email, password}. On success it sets a_factorial_idcookie (JWT) on.factorialhr.com, which is still accepted byapi.factorialhr.comfor the rest of the endpoints the CLI uses — no other code changes needed.422 invalid_credentialsresponses back to the existing"Invalid email or password"error so the CLI surface is unchanged.Test plan
npm run typechecknpm run test:e2e— login succeeds end-to-end and fills shifts against a real account (verified locally withFACTORIAL_PROJECT_NAMEset).🤖 Generated with Claude Code