Skip to content

Commit 59dda94

Browse files
authored
feat(api): enhance logging for mobile login endpoint (freeCodeCamp#59159)
1 parent c51218d commit 59dda94

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/src/routes/public/auth.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,21 @@ export const mobileAuth0Routes: FastifyPluginCallback = (
4343
fastify.get('/mobile-login', async (req, reply) => {
4444
const email = await getEmailFromAuth0(req);
4545

46+
const logger = fastify.log.child({ req });
47+
48+
logger.info('Mobile app login attempt');
49+
4650
if (!email) {
51+
logger.error('Could not get email from Auth0 to log in');
52+
4753
return reply.status(401).send({
4854
message: 'We could not log you in, please try again in a moment.',
4955
type: 'danger'
5056
});
5157
}
5258
if (!isEmail(email)) {
59+
logger.error('Email is incorrectly formatted for login');
60+
5361
return reply.status(400).send({
5462
message: 'The email is incorrectly formatted',
5563
type: 'danger'

0 commit comments

Comments
 (0)