diff --git a/examples/auth/cms/.env.example b/examples/auth/cms/.env.example index 71d3707dd2..fa72399827 100644 --- a/examples/auth/cms/.env.example +++ b/examples/auth/cms/.env.example @@ -1,6 +1,6 @@ PAYLOAD_PUBLIC_SITE_URL=http://localhost:3001 PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000 -MONGODB_URI=mongodb://localhost/payload-example-auth +MONGODB_URI=mongodb://127.0.0.1/payload-example-auth PAYLOAD_SECRET=PAYLOAD_AUTH_EXAMPLE_SECRET_KEY COOKIE_DOMAIN=localhost PAYLOAD_SEED=true diff --git a/examples/auth/cms/src/collections/hooks/protectRoles.ts b/examples/auth/cms/src/collections/hooks/protectRoles.ts index 33b15b80a3..ebb5a48678 100644 --- a/examples/auth/cms/src/collections/hooks/protectRoles.ts +++ b/examples/auth/cms/src/collections/hooks/protectRoles.ts @@ -3,7 +3,6 @@ import type { FieldHook } from 'payload/types' // ensure there is always a `user` role // do not let non-admins change roles -// eslint-disable-next-line consistent-return export const protectRoles: FieldHook = async ({ req, data }) => { const isAdmin = req.user?.roles.includes('admin') || data.email === 'demo@payloadcms.com' // for the seed script @@ -11,5 +10,8 @@ export const protectRoles: FieldHook = async ({ req, data return ['user'] } - return [...(data?.roles || []), 'user'] + const userRoles = new Set(data?.roles || []) + userRoles.add('user') + + return [...userRoles] } diff --git a/examples/auth/cms/tsconfig.json b/examples/auth/cms/tsconfig.json index 2ac7c29fee..92509a4924 100644 --- a/examples/auth/cms/tsconfig.json +++ b/examples/auth/cms/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es5", + "target": "es2019", "lib": [ "dom", "dom.iterable", @@ -14,10 +14,15 @@ "rootDir": "./src", "jsx": "react", "sourceMap": true, + "moduleResolution": "node", "resolveJsonModule": true, "paths": { - "payload/generated-types": ["./src/payload-types.ts"], - "node_modules/*": ["./node_modules/*"] + "payload/generated-types": [ + "./src/payload-types.ts" + ], + "node_modules/*": [ + "./node_modules/*" + ] }, }, "include": [ @@ -31,4 +36,4 @@ "ts-node": { "transpileOnly": true } -} +} \ No newline at end of file