mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-03 06:03:23 -05:00
chore(api): add user's id to errors sent to Sentry (#60725)
This commit is contained in:
committed by
GitHub
parent
892843f6d1
commit
a9dc3bdeef
@@ -67,6 +67,11 @@ const auth: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
};
|
||||
|
||||
if (isExpired(accessToken)) return setAccessDenied(req, TOKEN_EXPIRED);
|
||||
// We're using token.userId since it's possible for the user record to be
|
||||
// malformed and for prisma to throw while trying to find the user.
|
||||
fastify.Sentry?.setUser({
|
||||
id: accessToken.userId
|
||||
});
|
||||
|
||||
const user = await fastify.prisma.user.findUnique({
|
||||
where: { id: accessToken.userId }
|
||||
@@ -142,6 +147,12 @@ const auth: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
message: 'Token not found'
|
||||
};
|
||||
}
|
||||
// We're using token.userId since it's possible for the user record to be
|
||||
// malformed and for prisma to throw while trying to find the user.
|
||||
|
||||
fastify.Sentry?.setUser({
|
||||
id: token.userId
|
||||
});
|
||||
|
||||
const user = await fastify.prisma.user.findUnique({
|
||||
where: { id: token.userId }
|
||||
|
||||
Reference in New Issue
Block a user