mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-06 06:01:31 -05:00
fix(api): more informative auth errors (#61607)
This commit is contained in:
committed by
GitHub
parent
500342b24f
commit
55fbe40152
@@ -4,6 +4,7 @@ import { Type } from '@sinclair/typebox';
|
||||
import { Value } from '@sinclair/typebox/value';
|
||||
import fp from 'fastify-plugin';
|
||||
|
||||
import { isError } from 'lodash';
|
||||
import {
|
||||
API_LOCATION,
|
||||
AUTH0_CLIENT_ID,
|
||||
@@ -151,7 +152,14 @@ export const auth0Client: FastifyPluginCallbackTypebox = fp(
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error, 'Failed to get userinfo from Auth0');
|
||||
fastify.Sentry.captureException(error);
|
||||
if (isError(error) && 'innerError' in error) {
|
||||
// This is a specific error from the @fastify/oauth2 plugin.
|
||||
const innerError = error.innerError as Error;
|
||||
innerError.message = `Auth0 userinfo error: ${innerError.message}`;
|
||||
fastify.Sentry.captureException(error.innerError);
|
||||
} else {
|
||||
fastify.Sentry.captureException(error);
|
||||
}
|
||||
return reply.redirectWithMessage(returnTo, {
|
||||
type: 'danger',
|
||||
content: 'flash.generic-error'
|
||||
|
||||
Reference in New Issue
Block a user