Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

auth.js and qwik - Problem with adding the user role in the JWT #11643

Closed
gimonaa opened this issue Aug 21, 2024 · 1 comment
Closed

auth.js and qwik - Problem with adding the user role in the JWT #11643

gimonaa opened this issue Aug 21, 2024 · 1 comment
Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@gimonaa
Copy link

gimonaa commented Aug 21, 2024

Environment

  System:
    OS: Linux 5.10 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
    Memory: 968.16 MB / 5.79 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.10.0 - /usr/local/lib/nodejs/node-v20.10.0-linux-x64/bin/node
    Yarn: 1.22.15 - /usr/bin/yarn
    npm: 10.2.3 - /usr/local/lib/nodejs/node-v20.10.0-linux-x64/bin/npm
    pnpm: 9.0.5 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @auth/core: ^0.34.1 => 0.34.2 
    @auth/qwik: 0.2.2 => 0.2.2 

Reproduction URL

https://github.com/gimonaa/auth.qwik

Describe the issue

I would like to extend the user by also adding the role in the session. If I install only Qwik and add @auth/qwik, I can do this by extending JWT, User, and Session (in the types folder). However, if I add Prisma, the @auth/core folder is duplicated within @auth/qwik, and the extension is no longer recognized, resulting in an error where role is not defined.

Property role does not exist on type User | AdapterUser.

How to reproduce

if I delete the @auth/qwik/node_modules dir and its contents the problem disappears, then with an npm update the folder i recreated and the problem reappears

Expected behavior

the role error should not appear in the JWT callback

@gimonaa gimonaa added bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Aug 21, 2024
@balazsorban44
Copy link
Member

The issue seems to stem from these:

https://github.com/gimonaa/auth.qwik/blob/82c13d8a06b5f55164f17e26bdb91be1d43743db/package.json#L56

https://github.com/gimonaa/auth.qwik/blob/main/src/types/next-auth.d.ts

First, you should not need to have @auth/core installed in your project, only @auth/qwik.

Also, the type augmentation seems a bit messy. next-auth is not part of a Qwik project, so the import seems odd.

You should not augment node_modules, or @auth/core types just @auth/qwik

@nextauthjs nextauthjs locked and limited conversation to collaborators Aug 25, 2024
@balazsorban44 balazsorban44 converted this issue into discussion #11672 Aug 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

2 participants