Skip to content

Commit

Permalink
debug: Add console statements to diagnose build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonMeade committed Jun 21, 2024
1 parent 74173e5 commit 84e22c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}
};
Expand Down
15 changes: 14 additions & 1 deletion lib/redux/model/authentication/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthenticationState> => {

console.log("Logging in with credentials: ", credentials);

const client = new CognitoIdentityProviderClient({
region: process.env.NEXT_PUBLIC_AWS_REGION,
});
Expand Down Expand Up @@ -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(
Expand All @@ -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;
}
Expand Down Expand Up @@ -146,6 +154,9 @@ export const login = createAppAsyncThunk(
export const verifySession = createAppAsyncThunk(
"authentication/verifyAuthenticationAsync",
async (): Promise<AuthenticationState> => {

console.log("Verifying session");

const accessToken = sessionStorage.getItem("accessToken");
const idToken = sessionStorage.getItem("idToken");

Expand All @@ -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) {
Expand Down

0 comments on commit 84e22c5

Please sign in to comment.