From 84e22c56a507d258e687da747a76023b1542b16b Mon Sep 17 00:00:00 2001 From: Jackson Meade Date: Thu, 20 Jun 2024 23:04:52 -0400 Subject: [PATCH] debug: Add console statements to diagnose build issue --- app/login/page.tsx | 3 +++ lib/redux/model/authentication/thunks.ts | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/login/page.tsx b/app/login/page.tsx index 63ecea9..b113164 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -51,7 +51,10 @@ export default function LoginPage(): JSX.Element { const username = form.username.value; const password = form.password.value; + console.log("Logging in"); + if (username && password) { + console.log("Dispatching login action"); dispatch(login({ username, password })); } }; diff --git a/lib/redux/model/authentication/thunks.ts b/lib/redux/model/authentication/thunks.ts index 11d7128..ef30626 100644 --- a/lib/redux/model/authentication/thunks.ts +++ b/lib/redux/model/authentication/thunks.ts @@ -18,11 +18,13 @@ import { } from "../.."; import { createAppAsyncThunk } from "../../createAppAsyncThunk"; import { LoginCredentials } from "./types"; -import local from "next/font/local"; export const login = createAppAsyncThunk( "authentication/authenticateAsync", async (credentials: LoginCredentials): Promise => { + + console.log("Logging in with credentials: ", credentials); + const client = new CognitoIdentityProviderClient({ region: process.env.NEXT_PUBLIC_AWS_REGION, }); @@ -51,6 +53,9 @@ export const login = createAppAsyncThunk( }, }; } else { + + console.log("Auth response: ", authResponse); + const accessToken = authResponse.AuthenticationResult?.AccessToken; sessionStorage.setItem("accessToken", accessToken || ""); sessionStorage.setItem( @@ -73,8 +78,11 @@ export const login = createAppAsyncThunk( const getUserCommmand = new GetUserCommand({ AccessToken: accessToken, }); + console.log("Getting user with command: ", getUserCommmand); const userResponse = await client.send(getUserCommmand); + console.log("User response: ", userResponse); + if (!userResponse.Username || !userResponse.UserAttributes) { return nullState; } @@ -146,6 +154,9 @@ export const login = createAppAsyncThunk( export const verifySession = createAppAsyncThunk( "authentication/verifyAuthenticationAsync", async (): Promise => { + + console.log("Verifying session"); + const accessToken = sessionStorage.getItem("accessToken"); const idToken = sessionStorage.getItem("idToken"); @@ -165,7 +176,9 @@ export const verifySession = createAppAsyncThunk( const getUserCommmand = new GetUserCommand({ AccessToken: accessToken, }); + console.log("Getting user with command: ", getUserCommmand); const userResponse = await client.send(getUserCommmand); + console.log("User response: ", userResponse); return processUserResponse(userResponse, isAdmin); } catch (error: any) {