Chore/remove unused refresh arg (#6976)

## Description

The `refresh` operation was accepting a `token` argument, but it was not
being used at all. This PR cleans up that unused logic.
This commit is contained in:
James Mikrut
2024-06-28 10:52:41 -04:00
committed by GitHub
parent 39e34ce94e
commit 77e8ce980e
5 changed files with 3 additions and 36 deletions

View File

@@ -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<PayloadRequest>(context.req, 'transactionID'),
res: context.res,
token,
}
const result = await refresh(options)

View File

@@ -26,7 +26,6 @@ export type Arguments = {
collection: Collection
req: PayloadRequest
res?: Response
token: string
}
async function refresh(incomingArgs: Arguments): Promise<Result> {
@@ -66,7 +65,7 @@ async function refresh(incomingArgs: Arguments): Promise<Result> {
},
} = 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

View File

@@ -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<any> {
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({

View File

@@ -423,9 +423,6 @@ function initCollectionsGraphQL(payload: Payload): void {
},
},
}),
args: {
token: { type: GraphQLString },
},
resolve: refresh(collection),
}