mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat(api): enhance logging for mobile login endpoint (#59159)
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user