mirror of
https://github.com/complexcaresolutions/cms.c2sgmbh.git
synced 2026-03-17 15:04:14 +00:00
debug: fix types for 403 interceptors
This commit is contained in:
parent
26ceccbfb9
commit
36823b2d9f
1 changed files with 18 additions and 24 deletions
|
|
@ -133,36 +133,30 @@ const dirname = path.dirname(filename)
|
|||
export default buildConfig({
|
||||
// DEBUG: Log all API requests that result in 403
|
||||
onInit: async (payload) => {
|
||||
const originalFindGlobal = payload.findGlobal.bind(payload)
|
||||
payload.findGlobal = async (args: Parameters<typeof payload.findGlobal>[0]) => {
|
||||
try {
|
||||
return await originalFindGlobal(args)
|
||||
} catch (err: unknown) {
|
||||
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) {
|
||||
console.log('[DEBUG:403] Global read FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const origFindGlobal = payload.findGlobal.bind(payload) as any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(payload as any).findGlobal = async (args: any) => {
|
||||
try { return await origFindGlobal(args) } catch (err: any) {
|
||||
if (err?.status === 403) console.log('[DEBUG:403] Global read FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
|
||||
throw err
|
||||
}
|
||||
}
|
||||
const originalUpdate = payload.update.bind(payload)
|
||||
payload.update = async (args: Parameters<typeof payload.update>[0]) => {
|
||||
try {
|
||||
return await originalUpdate(args)
|
||||
} catch (err: unknown) {
|
||||
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) {
|
||||
console.log('[DEBUG:403] Collection update FORBIDDEN:', { collection: args.collection, id: args.id, user: args.req?.user?.email || 'no user' })
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const origUpdate = payload.update.bind(payload) as any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(payload as any).update = async (args: any) => {
|
||||
try { return await origUpdate(args) } catch (err: any) {
|
||||
if (err?.status === 403) console.log('[DEBUG:403] Collection update FORBIDDEN:', { collection: args.collection, id: args.id, user: args.req?.user?.email || 'no user' })
|
||||
throw err
|
||||
}
|
||||
}
|
||||
const originalUpdateGlobal = payload.updateGlobal.bind(payload)
|
||||
payload.updateGlobal = async (args: Parameters<typeof payload.updateGlobal>[0]) => {
|
||||
try {
|
||||
return await originalUpdateGlobal(args)
|
||||
} catch (err: unknown) {
|
||||
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) {
|
||||
console.log('[DEBUG:403] Global update FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const origUpdateGlobal = payload.updateGlobal.bind(payload) as any
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(payload as any).updateGlobal = async (args: any) => {
|
||||
try { return await origUpdateGlobal(args) } catch (err: any) {
|
||||
if (err?.status === 403) console.log('[DEBUG:403] Global update FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue