Skip to content

Commit c6054c5

Browse files
authored
fix: early return out of me access (#15883)
Closes #15822 Simple change, moves up the logic check to before the fetch so it returns early skipping a database call in some cases
1 parent e7d6331 commit c6054c5

File tree

1 file changed

+6
-6
lines changed
  • packages/payload/src/auth/operations

1 file changed

+6
-6
lines changed

packages/payload/src/auth/operations/me.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export const meOperation = async (args: Arguments): Promise<MeOperationResult> =
3838
}
3939

4040
if (req.user) {
41+
if (req.user.collection !== collection.config.slug) {
42+
return {
43+
user: null!,
44+
}
45+
}
46+
4147
const { pathname } = req
4248
const isGraphQL = pathname === `/api${req.payload.config.routes.graphQL}`
4349

@@ -59,12 +65,6 @@ export const meOperation = async (args: Arguments): Promise<MeOperationResult> =
5965
user._strategy = req.user._strategy
6066
}
6167

62-
if (req.user.collection !== collection.config.slug) {
63-
return {
64-
user: null!,
65-
}
66-
}
67-
6868
// /////////////////////////////////////
6969
// me hook - Collection
7070
// /////////////////////////////////////

0 commit comments

Comments
 (0)