diff --git a/app/components/layout/LogInButtonContainer.tsx b/app/components/layout/LogInButtonContainer.tsx
index 0de9d9abd..9385623ce 100644
--- a/app/components/layout/LogInButtonContainer.tsx
+++ b/app/components/layout/LogInButtonContainer.tsx
@@ -3,12 +3,15 @@ import { useTranslation } from "react-i18next";
import { LOG_IN_URL, SENDOU_INK_DISCORD_URL } from "~/utils/urls";
import { Button } from "../Button";
import { Dialog } from "../Dialog";
+import { createPortal } from "react-dom";
+import { useIsMounted } from "~/hooks/useIsMounted";
export function LogInButtonContainer({
children,
}: {
children: React.ReactNode;
}) {
+ const isMounted = useIsMounted();
const { t } = useTranslation();
const [searchParams, setSearchParams] = useSearchParams();
const authError = searchParams.get("authError");
@@ -23,14 +26,19 @@ export function LogInButtonContainer({
- {authError != null && (
-
- )}
+ {authError != null &&
+ isMounted &&
+ createPortal(
+ ,
+ document.body,
+ )}
>
);
}
diff --git a/app/features/auth/core/DiscordStrategy.server.ts b/app/features/auth/core/DiscordStrategy.server.ts
index 2f50c1bde..4e4e232dd 100644
--- a/app/features/auth/core/DiscordStrategy.server.ts
+++ b/app/features/auth/core/DiscordStrategy.server.ts
@@ -5,6 +5,7 @@ import { OAuth2Strategy } from "remix-auth-oauth2";
import invariant from "tiny-invariant";
import { z } from "zod";
import * as UserRepository from "~/features/user-page/UserRepository.server";
+import { logger } from "~/utils/logger";
interface DiscordExtraParams extends Record {
scope: string;
@@ -18,6 +19,7 @@ const partialDiscordUserSchema = z.object({
id: z.string(),
username: z.string(),
global_name: z.string().nullish(),
+ verified: z.boolean().nullish(),
});
const partialDiscordConnectionsSchema = z.array(
z.object({
@@ -63,6 +65,15 @@ export class DiscordStrategy extends OAuth2Strategy<
const [user, connections] =
discordUserDetailsSchema.parse(discordResponses);
+ const isAlreadyRegistered = Boolean(
+ await UserRepository.findByIdentifier(user.id),
+ );
+
+ if (!isAlreadyRegistered && !user.verified) {
+ logger.info(`User is not verified with id: ${user.id}`);
+ throw new Error("Unverified user");
+ }
+
const userFromDb = await UserRepository.upsert({
discordAvatar: user.avatar ?? null,
discordDiscriminator: user.discriminator,
@@ -80,7 +91,7 @@ export class DiscordStrategy extends OAuth2Strategy<
},
);
- this.scope = "identify connections";
+ this.scope = "identify connections email";
}
private authGatewayEnabled() {
diff --git a/locales/da/common.json b/locales/da/common.json
index 1ca35743d..ea337b222 100644
--- a/locales/da/common.json
+++ b/locales/da/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "logindforsøg afbrudt",
"auth.errors.failed": "Loginforsøg fejlet",
"auth.errors.discordPermissions": "Før at du kan oprette en profil på Sendou.ink, skal Sendou.ink have adgang til din Discordprofils navn, brugerbillede og sociale forbindelser (de sociale medier, som du har tilknyttet din discordprofil).",
- "auth.errors.unknown": "Log ind fejlet grundet en serverfejl. Prøv igen senere eller brug /login-kommandoen via Lohi-botten. Botten kan blive fundet på sendou.ink’s Discordserver",
"footer.github.subtitle": "Kildekode",
"footer.discord.subtitle": "Hjælp og feedback",
diff --git a/locales/en/common.json b/locales/en/common.json
index c632e5c6b..b61c22abf 100644
--- a/locales/en/common.json
+++ b/locales/en/common.json
@@ -33,7 +33,7 @@
"auth.errors.aborted": "Login Aborted",
"auth.errors.failed": "Login Failed",
"auth.errors.discordPermissions": "For your sendou.ink profile, the site needs access to your Discord profile's name, avatar and social connections.",
- "auth.errors.unknown": "The login failed due to a server error. Please try again later or use the /login command via the Lohi bot. The bot can be found on sendou.ink's Discord:",
+ "auth.errors.unknown": "Does your Discord account have a verified email? For help please reach out to us via the #helpdesk channel on our Discord:",
"footer.github.subtitle": "Source code",
"footer.discord.subtitle": "Help & feedback",
diff --git a/locales/fr/common.json b/locales/fr/common.json
index d7811d329..e8c0710b9 100644
--- a/locales/fr/common.json
+++ b/locales/fr/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "Connexion abandonnée",
"auth.errors.failed": "Connexion échouée",
"auth.errors.discordPermissions": "Pour mettre en place votre profil, sendou.ink a besoin de votre nom de profil Discord, de votre avatar et de vos réseaux connectés.",
- "auth.errors.unknown": "La connexion a échoué en raison d'une erreur de serveur. Veuillez réessayer plus tards ou utlisez la commande /login via le bot Lohi sur le serveur Discord:",
"footer.github.subtitle": "Code source",
"footer.discord.subtitle": "Aide & retours",
diff --git a/locales/he/common.json b/locales/he/common.json
index 54d3b2a48..ac1944cab 100644
--- a/locales/he/common.json
+++ b/locales/he/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "הכניסה בוטלה",
"auth.errors.failed": "הכניסה נכשלה",
"auth.errors.discordPermissions": "עבור פרופיל sendou.ink שלך, האתר זקוק לגישה לשם, הפרופיל והקשרים החברתיים של פרופיל ה-Discord שלך.",
- "auth.errors.unknown": "ההתחברות נכשלה עקב שגיאה בשרת. נסו שוב בבקשה או השתמשו בפקודה /login דרך הלוהי בוט. הבוט נמצא בשרת דיסקורד sendou.ink:",
"footer.github.subtitle": "קוד מקור",
"footer.discord.subtitle": "עזרה & משוב",
diff --git a/locales/pt-BR/common.json b/locales/pt-BR/common.json
index f6563f9f5..9a98acbb7 100644
--- a/locales/pt-BR/common.json
+++ b/locales/pt-BR/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "Login Abortado",
"auth.errors.failed": "Login Falhou",
"auth.errors.discordPermissions": "Para o seu perfil do sendou.ink, o site precisa de acesso ao nome do perfil do seu Discord, incluindo também o avatar e conexões sociais.",
- "auth.errors.unknown": "O login falhou devido a um erro do servidor. Por favor, tente novamente mais tarde ou use o comando /login através do bot Lohi. O bot pode ser encontrado no Discord do sendou.ink:",
"footer.github.subtitle": "Código fonte",
"footer.discord.subtitle": "Ajuda e Feedback",
diff --git a/locales/ru/common.json b/locales/ru/common.json
index 7bd1e692f..eb151d79d 100644
--- a/locales/ru/common.json
+++ b/locales/ru/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "Вход отменён",
"auth.errors.failed": "Ошибка входа",
"auth.errors.discordPermissions": "Для вашего профиля на sendou.ink странице нужет доступ к вашему имени, аватару и привязанным аккаунтам соц. сетей в Discord.",
- "auth.errors.unknown": "Логин не удался из-за серверной ошибки. Пожалуйста, повторите попытку позже или воспользуйтесь командой /login с помощью бота Lohi, которого можно найти на Discord сервере sendou.ink:",
"footer.github.subtitle": "Исходный код",
"footer.discord.subtitle": "Помощь и обратная связь",
diff --git a/locales/zh/common.json b/locales/zh/common.json
index 431d7763d..545aad30e 100644
--- a/locales/zh/common.json
+++ b/locales/zh/common.json
@@ -33,7 +33,6 @@
"auth.errors.aborted": "登录中止",
"auth.errors.failed": "登录失败",
"auth.errors.discordPermissions": "为了完善您的sendou.ink个人资料,网站需要获取您的Discord名字、头像和社交链接。",
- "auth.errors.unknown": "登录因服务器错误失败。请稍后重试或通过Lohi机器人使用/login指令。机器人可以在sendou.ink的Discord 中找到:",
"footer.github.subtitle": "源代码",
"footer.discord.subtitle": "帮助及反馈",