Sign out not clearing "spaceSlug" cookie (used in organizations) #3030

Closed
opened 2026-03-13 10:35:19 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Gustavo-Pauli on GitHub (Mar 11, 2026).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Login into an account with an active organization
  2. Logout
  3. Register or Login into an account that has no organizations

Current vs. Expected behavior

"spaceSlug" cookie should be cleaned on sign out or the spaceSlug should be cleaned on sign if the user has no organizations, so when you login into another account the spaceSlug is correct.

What version of Better Auth are you using?

1.4.17

System info

{
  "system": {
    "platform": "win32",        
    "arch": "x64",
    "version": "Windows 10 Pro",
    "release": "10.0.19045",
    "cpuCount": 6,
    "cpuModel": "Intel(R) Core(TM) i5-9600KF CPU @ 3.70GHz",
    "totalMemory": "31.91 GB",
    "freeMemory": "8.45 GB"
  },
  "node": {
    "version": "v22.14.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.2"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "16.1.1"
    },
    {
      "name": "react",
      "version": "19.1.0"
    }
  ],
  "databases": [
    {
      "name": "pg",
      "version": "^8.16.3"
    },
    {
      "name": "@prisma/client",
      "version": "^7.1.0"
    }
  ],
  "betterAuth": {
    "version": "1.4.17",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

export const auth = betterAuth({
  database: prismaAdapter(db, { provider: 'postgresql' }),
  rateLimit: {
    enabled: process.env.VERCEL_ENV === 'production',
  },

  session: {
    additionalFields: {
      activeOrgMemberId: {
        type: 'string',
        required: false,
        input: false,
      },
    },
  },
  emailAndPassword: {
    enabled: true,
    disableSignUp: process.env.VERCEL_ENV === 'production',
    autoSignIn: true,
  },

  plugins: [
    nextCookies(),
    organization({
      teams: {
        enabled: true,
        maximumTeams: 10,
        allowRemovingAllTeams: false,
        defaultTeamName: 'Matriz',
      },
      roles: { owner: ownerRole },
      ac: orgAccessControl,
      dynamicAccessControl: {
        enabled: true,
      },
      membershipLimit: 20,
    }),
  ]
)

Additional context

I know the org plugin is being reworked right now but i can take a look into fixing if needed.

Originally created by @Gustavo-Pauli on GitHub (Mar 11, 2026). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Login into an account with an active organization 2. Logout 3. Register or Login into an account that has no organizations ### Current vs. Expected behavior "spaceSlug" cookie should be cleaned on sign out or the spaceSlug should be cleaned on sign if the user has no organizations, so when you login into another account the spaceSlug is correct. ### What version of Better Auth are you using? 1.4.17 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 10 Pro", "release": "10.0.19045", "cpuCount": 6, "cpuModel": "Intel(R) Core(TM) i5-9600KF CPU @ 3.70GHz", "totalMemory": "31.91 GB", "freeMemory": "8.45 GB" }, "node": { "version": "v22.14.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.2" }, "frameworks": [ { "name": "next", "version": "16.1.1" }, { "name": "react", "version": "19.1.0" } ], "databases": [ { "name": "pg", "version": "^8.16.3" }, { "name": "@prisma/client", "version": "^7.1.0" } ], "betterAuth": { "version": "1.4.17", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript export const auth = betterAuth({ database: prismaAdapter(db, { provider: 'postgresql' }), rateLimit: { enabled: process.env.VERCEL_ENV === 'production', }, session: { additionalFields: { activeOrgMemberId: { type: 'string', required: false, input: false, }, }, }, emailAndPassword: { enabled: true, disableSignUp: process.env.VERCEL_ENV === 'production', autoSignIn: true, }, plugins: [ nextCookies(), organization({ teams: { enabled: true, maximumTeams: 10, allowRemovingAllTeams: false, defaultTeamName: 'Matriz', }, roles: { owner: ownerRole }, ac: orgAccessControl, dynamicAccessControl: { enabled: true, }, membershipLimit: 20, }), ] ) ``` ### Additional context I know the org plugin is being reworked right now but i can take a look into fixing if needed.
GiteaMirror added the nextjsbug labels 2026-03-13 10:35:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#3030