dont update session activeOrganizationId #338

Closed
opened 2026-03-13 07:42:15 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @productdevbook on GitHub (Dec 5, 2024).

unfortunately it is not updated when there are entries or when the activity changes, when there is an organization.

Originally created by @productdevbook on GitHub (Dec 5, 2024). unfortunately it is not updated when there are entries or when the activity changes, when there is an organization.
Author
Owner

@Bekacru commented on GitHub (Dec 5, 2024):

Please describe the issue better

@Bekacru commented on GitHub (Dec 5, 2024): Please describe the issue better
Author
Owner

@productdevbook commented on GitHub (Dec 5, 2024):

https://www.better-auth.com/docs/plugins/organization#session

activeOrganizationId is always empty. it never fills up. create org, change active etc.

@productdevbook commented on GitHub (Dec 5, 2024): https://www.better-auth.com/docs/plugins/organization#session activeOrganizationId is always empty. it never fills up. create org, change active etc.
Author
Owner

@Bekacru commented on GitHub (Dec 5, 2024):

could you show me your auth config or if It's open source I could take a look at the repo. And please if you use discord it's better to discuss this kind of issue there first :))

here is a link: https://discord.gg/GYC3W7tZzb

@Bekacru commented on GitHub (Dec 5, 2024): could you show me your auth config or if It's open source I could take a look at the repo. And please if you use discord it's better to discuss this kind of issue there first :)) here is a link: https://discord.gg/GYC3W7tZzb
Author
Owner

@devstojko commented on GitHub (Dec 20, 2024):

@Bekacru

Hello, I am playing around and I notice possible bug with organizations.

Steps to reproduce:

  1. Use api /organization/set-active​
  2. Set active organization slug
    image
  3. Call session api
    image

Notice how it set slug value instead of organization id to activeOrganizationId property

  1. Call get full organization
    image

It returns 400 because it can't find active organization with id (which is wrong in session)

If you set organizationId property on step 2 it will work as expected.

So here is expected behaviour if you use slug property to set active organization, internally it should find organization by slug, take ID from it and set that value in session.

@devstojko commented on GitHub (Dec 20, 2024): @Bekacru Hello, I am playing around and I notice possible bug with organizations. Steps to reproduce: 1. Use api `/organization/set-active​` 2. Set active organization slug <img width="1427" alt="image" src="https://github.com/user-attachments/assets/d674145a-ea51-4841-b8f0-4aea70ffce41" /> 3. Call session api <img width="329" alt="image" src="https://github.com/user-attachments/assets/ae06cc3e-2cd4-435a-9812-8f53ad90d17a" /> Notice how it set slug value instead of organization id to **activeOrganizationId** property 4. Call get full organization <img width="1136" alt="image" src="https://github.com/user-attachments/assets/281a7028-e234-4863-a0e2-71858f4d34f3" /> It returns 400 because it can't find active organization with id (which is wrong in session) If you set organizationId property on step 2 it will work as expected. So here is expected behaviour if you use slug property to set active organization, internally it should find organization by slug, take ID from it and set that value in session.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#338