-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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.getsubscription.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:
