fix: removing onlyNameIfPublic hook, causes confusion in other hooks
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user