Files
payloadcms/test/plugin-multi-tenant/config.ts
Jarrod Flesch 22633a6de6 fix(plugin-multi-tenant): remove tenant cookie on logout (#10761)
### What?
- Removes the tenant cookie when the user logs out
- Prevents double redirect to globals when no tenant is selected

### Why?
There were a couple scenarios where the cookie and the tenant did not
match, ie if you logged into 1 tenant, and then out and then into
another tenant.
2025-01-24 10:10:49 -05:00

50 lines
1.4 KiB
TypeScript

import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
import { fileURLToPath } from 'node:url'
import path from 'path'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
import type { Config as ConfigType } from './payload-types.js'
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
import { Menu } from './collections/Menu.js'
import { MenuItems } from './collections/MenuItems.js'
import { Tenants } from './collections/Tenants.js'
import { Users } from './collections/Users/index.js'
import { seed } from './seed/index.js'
import { menuItemsSlug, menuSlug } from './shared.js'
export default buildConfigWithDefaults({
collections: [Tenants, Users, MenuItems, Menu],
admin: {
autoLogin: false,
importMap: {
baseDir: path.resolve(dirname),
},
components: {
graphics: {
Logo: '/components/Logo/index.js#Logo',
Icon: '/components/Icon/index.js#Icon',
},
},
},
onInit: seed,
plugins: [
multiTenantPlugin<ConfigType>({
userHasAccessToAllTenants: (user) => Boolean(user.roles?.includes('admin')),
tenantField: {
access: {},
},
collections: {
[menuItemsSlug]: {},
[menuSlug]: {
isGlobal: true,
},
},
}),
],
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})