From 166bd31506e8698d31c53c2b67ec32fde80a84d3 Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Sat, 9 Jul 2022 19:38:24 -0400 Subject: [PATCH] feat: add res to token hooks --- src/auth/operations/logout.ts | 1 + src/auth/operations/refresh.ts | 1 + src/collections/config/types.ts | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/auth/operations/logout.ts b/src/auth/operations/logout.ts index b417d05930..3472ff06e8 100644 --- a/src/auth/operations/logout.ts +++ b/src/auth/operations/logout.ts @@ -45,6 +45,7 @@ async function logout(incomingArgs: Arguments): Promise { args = (await hook({ req, + res, })) || args; }, Promise.resolve()); diff --git a/src/auth/operations/refresh.ts b/src/auth/operations/refresh.ts index 5ca6bf3679..c9e7fc7bae 100644 --- a/src/auth/operations/refresh.ts +++ b/src/auth/operations/refresh.ts @@ -87,6 +87,7 @@ async function refresh(incomingArgs: Arguments): Promise { args = (await hook({ req: args.req, + res: args.res, exp, token: refreshedToken, })) || args; diff --git a/src/collections/config/types.ts b/src/collections/config/types.ts index 22e2645cfd..20bb1e91f7 100644 --- a/src/collections/config/types.ts +++ b/src/collections/config/types.ts @@ -2,6 +2,7 @@ import { DeepRequired } from 'ts-essentials'; import { PaginateModel } from 'mongoose'; import { GraphQLInputObjectType, GraphQLNonNull, GraphQLObjectType } from 'graphql'; +import { Response } from 'express'; import { Access, GeneratePreviewURL, EntityDescription, Endpoint } from '../../config/types'; import { Field } from '../../fields/config/types'; import { PayloadRequest } from '../../express/types'; @@ -124,6 +125,7 @@ export type AfterLoginHook = (args: { export type AfterLogoutHook = (args: { req: PayloadRequest; + res: Response; }) => any; export type AfterMeHook = (args: { @@ -133,6 +135,7 @@ export type AfterMeHook = (args: { export type AfterRefreshHook = (args: { req: PayloadRequest; + res: Response; token: string; exp: number; }) => any;