mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(api): log duplicate account ids (#60405)
This commit is contained in:
@@ -28,14 +28,20 @@ describe('findOrCreateUser', () => {
|
||||
});
|
||||
|
||||
it('should send a message to Sentry if there are multiple users with the same email', async () => {
|
||||
await fastify.prisma.user.create({ data: createUserInput(email) });
|
||||
await fastify.prisma.user.create({ data: createUserInput(email) });
|
||||
const user1 = await fastify.prisma.user.create({
|
||||
data: createUserInput(email)
|
||||
});
|
||||
const user2 = await fastify.prisma.user.create({
|
||||
data: createUserInput(email)
|
||||
});
|
||||
|
||||
const ids = [user1.id, user2.id];
|
||||
|
||||
await findOrCreateUser(fastify, email);
|
||||
|
||||
expect(captureException).toHaveBeenCalledTimes(1);
|
||||
expect(captureException).toHaveBeenCalledWith(
|
||||
new Error('Multiple user records found for: test@user.com')
|
||||
new Error(`Multiple user records found for: ${ids.join(', ')}`)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ export const findOrCreateUser = async (
|
||||
});
|
||||
if (existingUser.length > 1) {
|
||||
fastify.Sentry.captureException(
|
||||
new Error(`Multiple user records found for: ${email}`)
|
||||
new Error(
|
||||
`Multiple user records found for: ${existingUser.map(user => user.id).join(', ')}`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user