diff --git a/docs/authentication/operations.mdx b/docs/authentication/operations.mdx
index e4b571b62d..1499476f62 100644
--- a/docs/authentication/operations.mdx
+++ b/docs/authentication/operations.mdx
@@ -191,7 +191,7 @@ mutation {
### Refresh
-Allows for "refreshing" JWTs. If your user has a token that is about to expire, but the user is still active and using the app, you might want to use the `refresh` operation to receive a new token by sending the operation the token that is about to expire.
+Allows for "refreshing" JWTs. If your user has a token that is about to expire, but the user is still active and using the app, you might want to use the `refresh` operation to receive a new token by executing this operation via the authenticated user.
This operation requires a non-expired token to send back a new one. If the user's token has already expired, you will need to allow them to log in again to retrieve a new token.
@@ -237,13 +237,6 @@ mutation {
}
```
-
- The Refresh operation will automatically find the user's token in either a JWT header or the
- HTTP-only cookie. But, you can specify the token you're looking to refresh by providing the REST
- API with a `token` within the JSON body of the request, or by providing the GraphQL resolver a
- `token` arg.
-
-
### Verify by Email
If your collection supports email verification, the Verify operation will be exposed which accepts a verification token and sets the user's `_verified` property to `true`, thereby allowing the user to authenticate with the Payload API.
diff --git a/packages/payload/src/auth/graphql/resolvers/refresh.ts b/packages/payload/src/auth/graphql/resolvers/refresh.ts
index 453101fb9e..8140ba76c7 100644
--- a/packages/payload/src/auth/graphql/resolvers/refresh.ts
+++ b/packages/payload/src/auth/graphql/resolvers/refresh.ts
@@ -2,26 +2,15 @@ import type { Collection } from '../../../collections/config/types'
import type { PayloadRequest } from '../../../express/types'
import isolateObjectProperty from '../../../utilities/isolateObjectProperty'
-import getExtractJWT from '../../getExtractJWT'
import refresh from '../../operations/refresh'
function refreshResolver(collection: Collection) {
- async function resolver(_, args, context) {
- let token
-
- const extractJWT = getExtractJWT(context.req.payload.config)
- token = extractJWT(context.req)
-
- if (args.token) {
- token = args.token
- }
-
+ async function resolver(_, __, context) {
const options = {
collection,
depth: 0,
req: isolateObjectProperty(context.req, 'transactionID'),
res: context.res,
- token,
}
const result = await refresh(options)
diff --git a/packages/payload/src/auth/operations/refresh.ts b/packages/payload/src/auth/operations/refresh.ts
index c8feb51a44..ccc084f827 100644
--- a/packages/payload/src/auth/operations/refresh.ts
+++ b/packages/payload/src/auth/operations/refresh.ts
@@ -26,7 +26,6 @@ export type Arguments = {
collection: Collection
req: PayloadRequest
res?: Response
- token: string
}
async function refresh(incomingArgs: Arguments): Promise {
@@ -66,7 +65,7 @@ async function refresh(incomingArgs: Arguments): Promise {
},
} = args
- if (typeof args.token !== 'string' || !args.req.user) throw new Forbidden(args.req.t)
+ if (!args.req.user) throw new Forbidden(args.req.t)
const parsedURL = url.parse(args.req.url)
const isGraphQL = parsedURL.pathname === config.routes.graphQL
diff --git a/packages/payload/src/auth/requestHandlers/refresh.ts b/packages/payload/src/auth/requestHandlers/refresh.ts
index 75dfca0351..8c54f63238 100644
--- a/packages/payload/src/auth/requestHandlers/refresh.ts
+++ b/packages/payload/src/auth/requestHandlers/refresh.ts
@@ -2,7 +2,6 @@ import type { NextFunction, Response } from 'express'
import type { PayloadRequest } from '../../express/types'
-import getExtractJWT from '../getExtractJWT'
import refresh from '../operations/refresh'
export default async function refreshHandler(
@@ -11,20 +10,10 @@ export default async function refreshHandler(
next: NextFunction,
): Promise {
try {
- let token
-
- const extractJWT = getExtractJWT(req.payload.config)
- token = extractJWT(req)
-
- if (req.body.token) {
- token = req.body.token
- }
-
const result = await refresh({
collection: req.collection,
req,
res,
- token,
})
return res.status(200).json({
diff --git a/packages/payload/src/collections/graphql/init.ts b/packages/payload/src/collections/graphql/init.ts
index 5d13369599..0843eb0431 100644
--- a/packages/payload/src/collections/graphql/init.ts
+++ b/packages/payload/src/collections/graphql/init.ts
@@ -423,9 +423,6 @@ function initCollectionsGraphQL(payload: Payload): void {
},
},
}),
- args: {
- token: { type: GraphQLString },
- },
resolve: refresh(collection),
}