Skip to content

fix: migrate authentication to id.factorialhr.com - #344

Merged
DanielRamosAcosta merged 1 commit into
mainfrom
fix/new-id-factorialhr-auth
May 14, 2026
Merged

DanielRamosAcosta merged 1 commit into
mainfrom
fix/new-id-factorialhr-auth

Conversation

@DanielRamosAcosta

Copy link
Copy Markdown
Owner

Summary

  • Factorial moved the login form from api.factorialhr.com/es/users/sign_in to a SPA on id.factorialhr.com; the legacy endpoint now 302s away and no longer sets a _factorial_session_v2 cookie, so the CLI's login was broken.
  • Reimplemented FactorialAuthenticator against the new endpoint: a single JSON POST https://id.factorialhr.com/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.
  • Mapped 422 invalid_credentials responses back to the existing "Invalid email or password" error so the CLI surface is unchanged.
  • Updated the integration test to assert the new JWT shape instead of the old 32-char hex token.

Test plan

  • npm run typecheck
  • npm run test:e2e — login succeeds end-to-end and fills shifts against a real account (verified locally with FACTORIAL_PROJECT_NAME set).
  • CI green on this PR.

🤖 Generated with Claude Code

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>
@DanielRamosAcosta
DanielRamosAcosta merged commit 6a4255f into main May 14, 2026
2 checks passed
@DanielRamosAcosta
DanielRamosAcosta deleted the fix/new-id-factorialhr-auth branch May 14, 2026 09:53
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