Skip to content

Commit 3ccfd94

Browse files
VIA-254 Add temporary extra logging around session retrieval and auth callbacks
1 parent 5757a19 commit 3ccfd94

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
6060
},
6161

6262
async jwt({ token, account, profile }) {
63+
log.info("jwt / getToken callback invoked");
6364
let response;
6465
try {
6566
profilePerformanceStart(AuthJWTPerformanceMarker);
@@ -73,6 +74,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
7374
},
7475

7576
async session({ session, token }) {
77+
log.info("getsession callback invoked");
7678
let response;
7779
try {
7880
profilePerformanceStart(AuthSessionPerformanceMarker);

src/app/_components/vaccine/Vaccine.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import { getContentForVaccine } from "@src/services/content-api/content-service"
1515
import { ContentErrorTypes, StyledVaccineContent } from "@src/services/content-api/types";
1616
import { getEligibilityForPerson } from "@src/services/eligibility-api/domain/eligibility-filter-service";
1717
import { Eligibility, EligibilityErrorTypes } from "@src/services/eligibility-api/types";
18+
import { logger } from "@src/utils/logger";
1819
import { profilePerformanceEnd, profilePerformanceStart } from "@src/utils/performance";
1920
import { requestScopedStorageWrapper } from "@src/utils/requestScopedStorageWrapper";
2021
import { Session } from "next-auth";
2122
import React, { JSX } from "react";
2223

2324
import styles from "./styles.module.css";
2425

26+
const log = logger.child({ name: "vaccine component" });
27+
2528
interface VaccineProps {
2629
vaccineType: VaccineTypes;
2730
}
@@ -35,7 +38,9 @@ const Vaccine = async ({ vaccineType }: VaccineProps) => {
3538
const VaccineComponent = async ({ vaccineType }: VaccineProps): Promise<JSX.Element> => {
3639
profilePerformanceStart(VaccinePagePerformanceMarker);
3740

41+
log.info("vaccine component calling auth()");
3842
const session: Session | null = await auth();
43+
log.info("vaccine component auth() call complete");
3944
const nhsNumber: NhsNumber | undefined = session?.user.nhs_number as NhsNumber;
4045
const vaccineInfo: VaccineDetails = VaccineInfo[vaccineType];
4146

src/middleware.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ const middlewareWrapper = async (request: NextRequest) => {
2828
const config: AppConfig = await configProvider();
2929

3030
let response: NextResponse;
31+
log.info("middleware calling auth()");
3132
const session: Session | null = await auth();
33+
log.info("middleware auth() call complete");
34+
3235
if (!session?.user) {
3336
log.info({ context: { nextUrl: request.nextUrl.href } }, "Missing user session, redirecting to login");
3437
response = NextResponse.redirect(new URL(config.NHS_APP_REDIRECT_LOGIN_URL));

src/services/eligibility-api/gateway/fetch-eligibility-content.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export const fetchEligibilityContent = async (nhsNumber: NhsNumber): Promise<Eli
4141
};
4242

4343
if (config.IS_APIM_AUTH_ENABLED) {
44+
log.info("elid service fetching apim token");
4445
const apimAccessToken = await getApimAccessToken();
46+
log.info("elid service retrieved apim token");
4547
headers = { ...headers, Authorization: `Bearer ${apimAccessToken}` };
4648
}
4749

src/utils/auth/apim/get-apim-access-token.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ const getApimAccessToken = async (): Promise<AccessToken> => {
1616
*
1717
* @returns A Promise, resolving to the APIM access token.
1818
*/
19+
log.info("awaiting getJwtToken");
1920
const token = await getJwtToken();
21+
log.info("getJwtToken complete");
2022

2123
if (!token?.apim?.access_token) {
2224
log.error({ context: { token } }, "APIM access token is not present on JWT token");

0 commit comments

Comments
 (0)