From 59dda94259dcf6ad6fe635a085dfc2105cbc1041 Mon Sep 17 00:00:00 2001 From: Sem Bauke Date: Tue, 25 Mar 2025 03:05:32 +0100 Subject: [PATCH] feat(api): enhance logging for mobile login endpoint (#59159) --- api/src/routes/public/auth.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/src/routes/public/auth.ts b/api/src/routes/public/auth.ts index fcc67f216a4..b4d31d94541 100644 --- a/api/src/routes/public/auth.ts +++ b/api/src/routes/public/auth.ts @@ -43,13 +43,21 @@ export const mobileAuth0Routes: FastifyPluginCallback = ( fastify.get('/mobile-login', async (req, reply) => { const email = await getEmailFromAuth0(req); + const logger = fastify.log.child({ req }); + + logger.info('Mobile app login attempt'); + if (!email) { + logger.error('Could not get email from Auth0 to log in'); + return reply.status(401).send({ message: 'We could not log you in, please try again in a moment.', type: 'danger' }); } if (!isEmail(email)) { + logger.error('Email is incorrectly formatted for login'); + return reply.status(400).send({ message: 'The email is incorrectly formatted', type: 'danger'