Skip to content

[bug] Auth-optional components trigger UNAUTHORIZED errors #3051

@kaifaust

Description

@kaifaust

Components where auth should be optional call auth-required endpoints which trigger runtime auth errors.

Components where auth should be optional:

  • telemetry provider (wraps both marketing and logged in app)
  • top bar auth button
  • pricing table

relevant protectedProcedure endpoints:

  • user.get
  • subscription.get

We could modify protectedProcedure to allow a null ctx.user but that would require adding null checks to existing endpoints.

Instead, I think the cleanest solution is to make a new procedure and endpoints for components where auth is optional could be added. For example, we could create a new procedure (e.g. optionalAuthProcedure) that allows null ctx.user and similar endpoints (user.getOptional, etc.) that return null for unauthenticated users instead of throwing.

Screenshot of marketing page logs as an unauthorized visitor. Note the user.get and subscription.get throw errors and multiple retries:
Image

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions