From 2d8c66186c0c37228f11fbdf878961d2d9c1bdef Mon Sep 17 00:00:00 2001 From: tdgao Date: Fri, 17 Apr 2026 16:54:44 -0600 Subject: [PATCH] feat: implement under 13 DOB guard and email/password validation route --- .../src/components/ui/auth/CreateAccount.vue | 87 +++++++++++++++---- .../src/components/ui/auth/SignUp.vue | 53 +---------- apps/frontend/src/pages/auth/sign-up.vue | 57 ++++++++++-- .../src/modules/labrinth/auth/v2.ts | 16 ++++ .../api-client/src/modules/labrinth/types.ts | 6 ++ 5 files changed, 146 insertions(+), 73 deletions(-) diff --git a/apps/frontend/src/components/ui/auth/CreateAccount.vue b/apps/frontend/src/components/ui/auth/CreateAccount.vue index 288d1ab5c0..67e318f49e 100644 --- a/apps/frontend/src/components/ui/auth/CreateAccount.vue +++ b/apps/frontend/src/components/ui/auth/CreateAccount.vue @@ -15,25 +15,29 @@ -
You must be over 13 years old to use Modrinth.
- -
-
- {{ formatMessage(messages.infoPanelText) }} +
+ {{ formatMessage(messages.over13HelperText) }} +
+ + @@ -71,7 +75,7 @@ @@ -85,6 +89,7 @@ import { ButtonStyled, Checkbox, defineMessages, + injectNotificationManager, StyledInput, useVIntl, } from '@modrinth/ui' @@ -120,7 +125,7 @@ const props = defineProps({ sourceCodeUrl: { type: String, default: - 'https://github.com/modrinth/labrinth/blob/main/apps/labrinth/src/routes/internal/flows.rs', + 'https://github.com/modrinth/code/blob/main/apps/frontend/src/components/ui/auth/CreateAccount.vue', }, onCompleteSignUp: { type: Function, @@ -165,8 +170,40 @@ const maxBirthDate = computed(() => { return date.toISOString().slice(0, 10) }) +const isDateOfBirthMissing = computed(() => props.requiresDob && dateOfBirthModel.value === '') + +const isUnder13 = computed( + () => + props.requiresDob && + dateOfBirthModel.value !== '' && + dateOfBirthModel.value > maxBirthDate.value, +) + +const { addNotification } = injectNotificationManager() const { formatMessage } = useVIntl() +function onCompleteSignUpClick() { + if (isDateOfBirthMissing.value) { + addNotification({ + title: formatMessage(messages.dateOfBirthRequiredTitle), + text: formatMessage(messages.dateOfBirthRequiredText), + type: 'warning', + }) + return + } + + if (isUnder13.value) { + addNotification({ + title: formatMessage(messages.ageRequirementWarningTitle), + text: formatMessage(messages.under13HelperText), + type: 'error', + }) + return + } + + props.onCompleteSignUp() +} + const messages = defineMessages({ title: { id: 'auth.create-account.title', @@ -176,10 +213,26 @@ const messages = defineMessages({ id: 'auth.create-account.date-of-birth.label', defaultMessage: 'Date of birth', }, + dateOfBirthRequiredTitle: { + id: 'auth.create-account.date-of-birth.required.title', + defaultMessage: 'Date of birth required', + }, + dateOfBirthRequiredText: { + id: 'auth.create-account.date-of-birth.required.text', + defaultMessage: 'Please enter your date of birth before continuing.', + }, over13HelperText: { id: 'auth.create-account.date-of-birth.over13-helper', defaultMessage: 'You must be over 13 years old to use Modrinth.', }, + under13HelperText: { + id: 'auth.create-account.date-of-birth.under13-helper', + defaultMessage: 'You cannot create an account at Modrinth unless you are 13 years old.', + }, + ageRequirementWarningTitle: { + id: 'auth.create-account.age-requirement.warning-title', + defaultMessage: 'Age requirement', + }, infoPanelText: { id: 'auth.create-account.info-panel.text', defaultMessage: diff --git a/apps/frontend/src/components/ui/auth/SignUp.vue b/apps/frontend/src/components/ui/auth/SignUp.vue index 9b46aca712..e12ebd14b1 100644 --- a/apps/frontend/src/components/ui/auth/SignUp.vue +++ b/apps/frontend/src/components/ui/auth/SignUp.vue @@ -79,13 +79,6 @@ wrapper-class="w-full" /> -