diff --git a/examples/auth/cms/src/collections/Users.ts b/examples/auth/cms/src/collections/Users.ts index 7006e42cb7..c02b1a5ec2 100644 --- a/examples/auth/cms/src/collections/Users.ts +++ b/examples/auth/cms/src/collections/Users.ts @@ -43,6 +43,7 @@ export const Users: CollectionConfig = { name: 'roles', type: 'select', hasMany: true, + saveToJWT: true, hooks: { beforeChange: [protectRoles], }, diff --git a/examples/auth/cms/src/collections/hooks/protectRoles.ts b/examples/auth/cms/src/collections/hooks/protectRoles.ts index ebb5a48678..9c4c9af7c5 100644 --- a/examples/auth/cms/src/collections/hooks/protectRoles.ts +++ b/examples/auth/cms/src/collections/hooks/protectRoles.ts @@ -10,7 +10,7 @@ export const protectRoles: FieldHook = async ({ req, data return ['user'] } - const userRoles = new Set(data?.roles || []) + const userRoles = new Set(...(data?.roles || [])) userRoles.add('user') return [...userRoles]