Skip to content

Commit

Permalink
feat: add random user for local testing
Browse files Browse the repository at this point in the history
  • Loading branch information
PAYNEA03 committed Sep 9, 2024
1 parent 4831942 commit 5b860fb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/api/headers/user/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ const decodeJWT = (token: string): JwtPayload | null => {
export async function GET() {
try {
const userToken = headers().get('x-amzn-oidc-data');
const randomUserName = `ABC-${Math.floor(Math.random() * 100)}`;

if (userToken == null) {
return NextResponse.json('No Token In Header', {
status: 404,
statusText: 'Not Found',
logger.debug('No token in header, setting random user name');
return NextResponse.json(randomUserName, {
status: 200,
statusText: 'OK',
});
}

Expand All @@ -38,7 +40,8 @@ export async function GET() {
statusText: 'OK',
});
}
return NextResponse.json(`ABC-${Math.floor(Math.random() * 100)}`, {

return NextResponse.json(randomUserName, {
status: 200,
statusText: 'OK',
});
Expand Down

0 comments on commit 5b860fb

Please sign in to comment.