chore: pulls mongodb from main

This commit is contained in:
James
2024-02-16 11:27:23 -05:00
parent abf0f7111d
commit 12c5100bc8
28 changed files with 567 additions and 507 deletions

View File

@@ -35,12 +35,8 @@ export default buildConfigWithDefaults({
name: 'adminOnlyField',
type: 'text',
access: {
read: ({
req: {
user: { roles = [] },
},
}) => {
return roles.includes('admin')
read: ({ req: { user } }) => {
return user?.roles?.includes('admin')
},
},
},
@@ -177,7 +173,8 @@ export default buildConfigWithDefaults({
},
access: {
read: ({ req: { user } }) => {
if (user.collection === 'api-keys') {
if (!user) return false
if (user?.collection === 'api-keys') {
return {
id: {
equals: user.id,

View File

@@ -6,7 +6,7 @@ import type { User } from '../../packages/payload/src/auth'
import { getPayload } from '../../packages/payload/src'
import { devUser } from '../credentials'
import { NextRESTClient } from '../helpers/NextRESTClient'
import { startMemoryDB } from '../startMemoryDB'
// import { startMemoryDB } from '../startMemoryDB'
import configPromise from './config'
import { namedSaveToJWTValue, saveToJWTKey, slug } from './shared'
@@ -18,8 +18,8 @@ const { email, password } = devUser
describe('Auth', () => {
beforeAll(async () => {
const config = await startMemoryDB(configPromise)
payload = await getPayload({ config })
// const config = await startMemoryDB(configPromise)
payload = await getPayload({ config: configPromise })
restClient = new NextRESTClient(payload.config)
})
@@ -33,24 +33,32 @@ describe('Auth', () => {
let token
let user
beforeAll(async () => {
const { data } = await restClient
.GRAPHQL_POST({
body: JSON.stringify({
query: `mutation {
loginUser(email: "${devUser.email}", password: "${devUser.password}") {
token
user {
id
email
}
}
}`,
}),
})
.then((res) => res.json())
const result = await payload.login({
collection: 'users',
data: {
email: devUser.email,
password: devUser.password,
},
})
user = data.loginUser.user
token = data.loginUser.token
// const { data } = await restClient
// .GRAPHQL_POST({
// body: JSON.stringify({
// query: `mutation {
// loginUser(email: "${devUser.email}", password: "${devUser.password}") {
// token
// user {
// id
// email
// }
// }
// }`,
// }),
// })
// .then((res) => res.json())
user = result.user
token = result.token
})
it('should login', async () => {