From 5545b8e0a37b9bfdbad7b97a4f88d840eab97a2f Mon Sep 17 00:00:00 2001 From: Miodec Date: Thu, 31 Mar 2022 19:47:18 +0200 Subject: [PATCH] added error message if user is already linked closes #2794 --- backend/api/controllers/user.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/api/controllers/user.ts b/backend/api/controllers/user.ts index 4103efb00..1d7c535e7 100644 --- a/backend/api/controllers/user.ts +++ b/backend/api/controllers/user.ts @@ -127,6 +127,12 @@ export async function linkDiscord( const useRedisForBotTasks = req.ctx.configuration.useRedisForBotTasks.enabled; const userInfo = await UsersDAO.getUser(uid); + if (userInfo.discordId) { + throw new MonkeyError( + 409, + "This account is already linked to a Discord account" + ); + } if (userInfo.banned) { throw new MonkeyError(403, "Banned accounts cannot link with Discord"); } @@ -145,7 +151,7 @@ export async function linkDiscord( if (!discordIdAvailable) { throw new MonkeyError( 409, - "This Discord account is already linked to a different account" + "This Discord account is linked to a different account" ); }