Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Undefined user object from getAuth() #89

Open
teddybee opened this issue Sep 21, 2023 · 0 comments
Open

Undefined user object from getAuth() #89

teddybee opened this issue Sep 21, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@teddybee
Copy link

teddybee commented Sep 21, 2023

Describe the bug
I am using t3-app and I would like to check the user's role in the trpc`s middleware.
I added an auth object this way

const auth = getAuth(opts.req as RequestLike);

Unfortunately the user in the auth object is undefined. Is it a bug, or I need some additional coding to get the user object and role in privateMetadata?
Is it the same issue in the next middleware, in the withClerkMiddleware() function.

const { user, userId,  } = getAuth(request);   

User object is undefined.

To Reproduce

Expected behavior
User object is populated.

Logs
Please provide logs showing the error.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: windows 11
  • Browser chrome
  • Version 117
  • NodeJS 20.6.3
  • Nextjs 13.5.2
  • CreateT3app 7.20.2
  • "@trpc/server": "^10.38.3",
  • "@clerk/nextjs": "^4.24.0",

Additional context

@teddybee teddybee added the bug Something isn't working label Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant