create-payload-app 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,3 @@
|
|
1
|
-
const onlyNameIfPublic = ({ req: { user }, doc }) => {
|
2
|
-
// Only return name if not logged in
|
3
|
-
if (!user) {
|
4
|
-
return { name: doc.name };
|
5
|
-
}
|
6
|
-
return doc;
|
7
|
-
};
|
8
|
-
|
9
1
|
const Users = {
|
10
2
|
slug: 'users',
|
11
3
|
auth: true,
|
@@ -15,9 +7,6 @@ const Users = {
|
|
15
7
|
access: {
|
16
8
|
read: () => true,
|
17
9
|
},
|
18
|
-
hooks: {
|
19
|
-
beforeRead: [onlyNameIfPublic]
|
20
|
-
},
|
21
10
|
fields: [
|
22
11
|
// Email added by default
|
23
12
|
{
|
@@ -1,14 +1,5 @@
|
|
1
|
-
import { BeforeReadHook } from 'payload/dist/collections/config/types';
|
2
1
|
import { CollectionConfig } from 'payload/types';
|
3
2
|
|
4
|
-
const onlyNameIfPublic: BeforeReadHook = ({ req: { user }, doc }) => {
|
5
|
-
// Only return name if not logged in
|
6
|
-
if (!user) {
|
7
|
-
return { name: doc.name };
|
8
|
-
}
|
9
|
-
return doc;
|
10
|
-
};
|
11
|
-
|
12
3
|
const Users: CollectionConfig = {
|
13
4
|
slug: 'users',
|
14
5
|
auth: true,
|
@@ -18,9 +9,6 @@ const Users: CollectionConfig = {
|
|
18
9
|
access: {
|
19
10
|
read: () => true,
|
20
11
|
},
|
21
|
-
hooks: {
|
22
|
-
beforeRead: [onlyNameIfPublic]
|
23
|
-
},
|
24
12
|
fields: [
|
25
13
|
// Email added by default
|
26
14
|
{
|