fix: removing onlyNameIfPublic hook, causes confusion in other hooks

This commit is contained in:
Elliot DeNolf
2022-02-13 08:57:31 -05:00
parent 0ce5d774cb
commit c168bb5201
2 changed files with 1 additions and 23 deletions

View File

@@ -1,11 +1,3 @@
const onlyNameIfPublic = ({ req: { user }, doc }) => {
// Only return name if not logged in
if (!user) {
return { name: doc.name };
}
return doc;
};
const Users = {
slug: 'users',
auth: true,
@@ -15,9 +7,6 @@ const Users = {
access: {
read: () => true,
},
hooks: {
beforeRead: [onlyNameIfPublic]
},
fields: [
// Email added by default
{

View File

@@ -1,12 +1,4 @@
import { CollectionBeforeReadHook, CollectionConfig } from 'payload/types';
const onlyNameIfPublic: CollectionBeforeReadHook = ({ req: { user }, doc }) => {
// Only return name if not logged in
if (!user) {
return { name: doc.name };
}
return doc;
};
import { CollectionConfig } from 'payload/types';
const Users: CollectionConfig = {
slug: 'users',
@@ -17,9 +9,6 @@ const Users: CollectionConfig = {
access: {
read: () => true,
},
hooks: {
beforeRead: [onlyNameIfPublic]
},
fields: [
// Email added by default
{