Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solucionando la re-autenticación/refresco de tokens en el cliente #33

Merged
merged 2 commits into from
Jun 22, 2024

Conversation

fforres
Copy link
Member

@fforres fforres commented Jun 22, 2024

PR Agrega un link de manejo de errores de graphql, donde si detecta un error de autenticación, fuerza un refresco de la token de supabase.
Además, promueve los errores de graphql que encuentre a errores de JS. Cuando esto ocurre, las queries que causaron el error capturadas por el retry-link y reintentadas.
En ese momento, la token ya debería estar actualizada y la query pasar sin problemas :)

Dependemos de JSConfCL/gql_api#168

Caveats:

  • No tenemos por ahora multiples queries paralelas, pero esto podría causear varios token-refresh simultaneos. No debería ser problema, pero eventualmente deberíamos tener una cola de retry.
  • No he revisado otro tipo de errores de graphql. Por ahora, capturamos el auth, pero deberíamos revisar que otros errores no causen retries innecesarios. Fixed :)

Copy link

socket-security bot commented Jun 22, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/[email protected] None 0 13.5 kB types
npm/[email protected] None 0 13.9 kB auth0-oss

View full report↗︎

@fforres fforres changed the title Handling reauthentication/token refresh flow on graphql errors @fforres Solucionando la re-autenticación/refresco de tokens en el cliente Jun 22, 2024
@fforres fforres changed the title @fforres Solucionando la re-autenticación/refresco de tokens en el cliente Solucionando la re-autenticación/refresco de tokens en el cliente Jun 22, 2024
Copy link

cloudflare-workers-and-pages bot commented Jun 22, 2024

Deploying tickets with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba12c04
Status: ✅  Deploy successful!
Preview URL: https://64ae3e94.tickets.pages.dev
Branch Preview URL: https://fforres-handling-reauthentic.tickets.pages.dev

View logs

@fforres fforres force-pushed the fforres/handling_reauthentication branch from d81aaa1 to ba12c04 Compare June 22, 2024 17:19
@fforres fforres marked this pull request as ready for review June 22, 2024 17:19
@fforres fforres marked this pull request as draft June 22, 2024 17:20
@fforres fforres marked this pull request as ready for review June 22, 2024 17:21
fforres added a commit to JSConfCL/gql_api that referenced this pull request Jun 22, 2024
Ahora si el usuario tiene un token expirado, exponemos un error custom
de graphql `UNAUTHENTICATED`.
Quiero agregar un code 401, pero necesito limpiar un poco nuestro
frontend, (quizas incluso remover SSR, es mas atadoso que simple en
nuestro caso, onda para consolidar queries autenticadas cross-env)

Desbloquea JSConfCL/tickets#33
@fforres fforres merged commit 005b441 into main Jun 22, 2024
4 checks passed
@fforres fforres deleted the fforres/handling_reauthentication branch June 22, 2024 19:54
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.

2 participants