Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 91fb9d4

Browse files
committed
Enhance restaurantLoginHandler with additional logging for better traceability of restaurant and user details
1 parent 99d4ab6 commit 91fb9d4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
},
2929
"dependencies": {
3030
"source-map-support": "^0.5.21"
31-
}
31+
},
32+
"packageManager": "pnpm@10.6.4+sha512.da3d715bfd22a9a105e6e8088cfc7826699332ded60c423b14ec613a185f1602206702ff0fe4c438cb15c979081ce4cb02568e364b15174503a63c7a8e2a5f6c"
3233
}

src/lambdas/auth.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,29 +169,30 @@ export const restaurantLoginHandler = async (event: { [key: string]: any }) => {
169169
TableName: getResourceName(envName, 'restaurants'),
170170
Key: marshall({ restaurantId }),
171171
});
172-
172+
logger.info('Getting restaurant details', getItemCommand);
173173
const result = (await dynamoClient.send(getItemCommand)).Item;
174+
logger.info('Restaurant details', result);
174175
if (!result) {
175176
return {
176177
statusCode: 404,
177178
body: JSON.stringify({ message: 'Restaurant not found' }),
178179
};
179180
}
180181
const parsedResult = unmarshall(result);
182+
logger.info('Parsed restaurant details', parsedResult);
181183
const user = parsedResult.users.find((user: any) => user.id === userId);
182184
if (!user) {
183185
return {
184186
statusCode: 401,
185187
body: JSON.stringify({ message: 'User not found' }),
186188
};
187189
}
188-
190+
logger.info('User found', user);
189191
const isAuthorized = await bcrypt.compare(password, user.password);
190-
192+
logger.info('Is authorized', isAuthorized);
191193
if (isAuthorized) {
192-
console.log('User authorized');
194+
logger.info('User authorized');
193195
const jwt = generateToken({ restaurantId });
194-
195196
return {
196197
statusCode: 200,
197198
body: JSON.stringify({ jwt }),

0 commit comments

Comments
 (0)