Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(app): show terms at sign-up as a notice, not a checkbox

Hampus4629872db9d4
diff --git a/fluxer_app/src/features/auth/flow/AuthPageStyles.module.css b/fluxer_app/src/features/auth/flow/AuthPageStyles.module.css
index 6bba2cd4f..5258e310d 100644
--- a/fluxer_app/src/features/auth/flow/AuthPageStyles.module.css
+++ b/fluxer_app/src/features/auth/flow/AuthPageStyles.module.css
@@ -53,6 +53,10 @@
flex-direction: column;
}
+.loginHeader {
+ margin-bottom: 1.25rem;
+}
+
.entityHeader {
display: flex;
flex-direction: column;
@@ -181,7 +185,7 @@ img.entityIcon {
.bottomLink {
margin-top: 1rem;
- text-align: left;
+ text-align: start;
}
.bottomLinkText {
@@ -229,20 +233,20 @@ img.entityIcon {
margin-top: 0.25rem;
display: block;
font-size: 0.75rem;
- color: var(--status-danger);
+ color: color-mix(in srgb, var(--status-danger) 78%, var(--text-primary) 22%);
}
-.consentRow {
- display: flex;
- align-items: flex-start;
- gap: 0.5rem;
-}
-
-.consentLabel {
- padding-top: 0.125rem;
+.legalNotice {
+ margin: 0;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--text-primary);
+ overflow-wrap: anywhere;
+}
+
+.legalNotice .policyLink {
+ text-decoration: underline;
+ text-underline-offset: 0.125rem;
}
.policyLink {
@@ -327,3 +331,11 @@ img.entityIcon {
line-height: 1.5;
color: var(--text-tertiary);
}
+
+.consentLine {
+ margin: 0;
+ font-size: 0.75rem;
+ line-height: 1rem;
+ color: var(--text-tertiary);
+ text-align: center;
+}
diff --git a/fluxer_app/src/features/auth/flow/MockMinimalRegisterForm.tsx b/fluxer_app/src/features/auth/flow/MockMinimalRegisterForm.tsx
index 80992a493..328e9b2c1 100644
--- a/fluxer_app/src/features/auth/flow/MockMinimalRegisterForm.tsx
+++ b/fluxer_app/src/features/auth/flow/MockMinimalRegisterForm.tsx
@@ -1,34 +1,13 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import {Routes} from '@app/app/Routes';
-import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
import authStyles from '@app/features/auth/flow/AuthPageStyles.module.css';
-import dobStyles from '@app/features/auth/flow/DateOfBirthField.module.css';
+import {RegistrationLegalNotice} from '@app/features/auth/flow/RegistrationLegalNotice';
import {WHAT_SHOULD_PEOPLE_CALL_YOU_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
import {PASSWORD_MANAGER_IGNORE_ATTRIBUTES} from '@app/features/platform/utils/PasswordManagerAutocomplete';
import {Button} from '@app/features/ui/button/Button';
-import {Checkbox} from '@app/features/ui/checkbox/Checkbox';
import inputStyles from '@app/features/ui/components/form/FormInput.module.css';
-import {getCurrentLocale} from '@app/features/user/utils/LocaleUtils';
-import {getDateFieldOrder} from '@fluxer/date_utils/src/DateIntrospection';
-import {msg} from '@lingui/core/macro';
import {Trans, useLingui} from '@lingui/react/macro';
-import {useMemo} from 'react';
-
-const MONTH_DESCRIPTOR = msg({
- message: 'Month',
- comment: 'Short label in the authentication mock minimal register form. Keep the tone plain and specific.',
-});
-const DAY_DESCRIPTOR = msg({
- message: 'Day',
- comment: 'Short label in the authentication mock minimal register form. Keep the tone plain and specific.',
-});
-const YEAR_DESCRIPTOR = msg({
- message: 'Year',
- comment: 'Short label in the authentication mock minimal register form. Keep the tone plain and specific.',
-});
-
-type DateFieldType = 'month' | 'day' | 'year';
interface MockMinimalRegisterFormProps {
submitLabel: React.ReactNode;
@@ -36,50 +15,6 @@ interface MockMinimalRegisterFormProps {
export function MockMinimalRegisterForm({submitLabel}: MockMinimalRegisterFormProps) {
const {i18n} = useLingui();
- const locale = getCurrentLocale();
- const fieldOrder = useMemo(() => getDateFieldOrder(locale), [locale]);
- const dateFields: Record<DateFieldType, React.ReactElement> = {
- month: (
- <div key="month" className={dobStyles.monthField} data-flx="auth.flow.mock-minimal-register-form.div">
- <input
- type="text"
- data-flx="auth.flow.mock-minimal-register-form.input.text"
- {...PASSWORD_MANAGER_IGNORE_ATTRIBUTES}
- readOnly
- tabIndex={-1}
- placeholder={i18n._(MONTH_DESCRIPTOR)}
- className={inputStyles.input}
- />
- </div>
- ),
- day: (
- <div key="day" className={dobStyles.dayField} data-flx="auth.flow.mock-minimal-register-form.div--2">
- <input
- type="text"
- data-flx="auth.flow.mock-minimal-register-form.input.text--2"
- {...PASSWORD_MANAGER_IGNORE_ATTRIBUTES}
- readOnly
- tabIndex={-1}
- placeholder={i18n._(DAY_DESCRIPTOR)}
- className={inputStyles.input}
- />
- </div>
- ),
- year: (
- <div key="year" className={dobStyles.yearField} data-flx="auth.flow.mock-minimal-register-form.div--3">
- <input
- type="text"
- data-flx="auth.flow.mock-minimal-register-form.input.text--3"
- {...PASSWORD_MANAGER_IGNORE_ATTRIBUTES}
- readOnly
- tabIndex={-1}
- placeholder={i18n._(YEAR_DESCRIPTOR)}
- className={inputStyles.input}
- />
- </div>
- ),
- };
- const orderedFields = fieldOrder.map((fieldType) => dateFields[fieldType]);
return (
<div className={authStyles.form} data-flx="auth.flow.mock-minimal-register-form.div--4">
<div className={inputStyles.fieldset} data-flx="auth.flow.mock-minimal-register-form.div--5">
@@ -100,42 +35,10 @@ export function MockMinimalRegisterForm({submitLabel}: MockMinimalRegisterFormPr
/>
</div>
</div>
- <div className={dobStyles.fieldset} data-flx="auth.flow.mock-minimal-register-form.div--8">
- <div className={dobStyles.labelContainer} data-flx="auth.flow.mock-minimal-register-form.div--9">
- <span className={dobStyles.legend} data-flx="auth.flow.mock-minimal-register-form.span--2">
- <Trans>Date of birth</Trans>
- </span>
- </div>
- <div className={dobStyles.inputsContainer} data-flx="auth.flow.mock-minimal-register-form.div--10">
- <div className={dobStyles.fieldsRow} data-flx="auth.flow.mock-minimal-register-form.div--11">
- {orderedFields}
- </div>
- </div>
- </div>
- <div className={authStyles.consentRow} data-flx="auth.flow.mock-minimal-register-form.div--12">
- <Checkbox checked={false} onChange={() => {}} disabled data-flx="auth.flow.mock-minimal-register-form.checkbox">
- <span className={authStyles.consentLabel} data-flx="auth.flow.mock-minimal-register-form.span--3">
- <Trans>
- I agree to the{' '}
- <ExternalLink
- href={Routes.terms()}
- className={authStyles.policyLink}
- data-flx="auth.flow.mock-minimal-register-form.external-link"
- >
- Terms of service
- </ExternalLink>{' '}
- and{' '}
- <ExternalLink
- href={Routes.privacy()}
- className={authStyles.policyLink}
- data-flx="auth.flow.mock-minimal-register-form.external-link--2"
- >
- Privacy policy
- </ExternalLink>
- </Trans>
- </span>
- </Checkbox>
- </div>
+ <RegistrationLegalNotice
+ config={{termsUrl: Routes.terms(), privacyUrl: Routes.privacy(), requirement: 'terms_and_privacy'}}
+ data-flx="auth.flow.mock-minimal-register-form.registration-legal-notice"
+ />
<Button type="button" fitContainer disabled data-flx="auth.flow.mock-minimal-register-form.button">
{submitLabel}
</Button>
diff --git a/fluxer_app/src/features/auth/flow/RegistrationLegalConsent.tsx b/fluxer_app/src/features/auth/flow/RegistrationLegalConsent.tsx
deleted file mode 100644
index 9866aa731..000000000
--- a/fluxer_app/src/features/auth/flow/RegistrationLegalConsent.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-or-later
-
-import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
-import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';
-import styles from '@app/features/auth/flow/AuthPageStyles.module.css';
-import type {LegalConsentRequirement} from '@app/features/auth/flow/SubmitTooltip';
-import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
-import {Checkbox} from '@app/features/ui/checkbox/Checkbox';
-import {flxElementClassName} from '@app/lib/react';
-import {Trans} from '@lingui/react/macro';
-import type {ReactElement} from 'react';
-
-export interface RegistrationLegalConsentConfig {
- termsUrl: string | null;
- privacyUrl: string | null;
- requirement: LegalConsentRequirement | null;
-}
-
-function resolveLegalConsentRequirement(
- termsUrl: string | null,
- privacyUrl: string | null,
-): LegalConsentRequirement | null {
- if (termsUrl != null && privacyUrl != null) {
- return 'terms_and_privacy';
- }
- if (termsUrl != null) {
- return 'terms';
- }
- if (privacyUrl != null) {
- return 'privacy';
- }
- return null;
-}
-
-export function getRegistrationLegalConsentConfig(
- runtimeSnapshot: RuntimeConfigSnapshot,
- showLegalConsent = true,
-): RegistrationLegalConsentConfig {
- const isSelfHosted = DeveloperOptions.selfHostedModeOverride || runtimeSnapshot.features.self_hosted;
- const termsUrl =
- runtimeSnapshot.appPublic.legal.terms_url ?? (isSelfHosted ? null : `${runtimeSnapshot.marketingEndpoint}/terms`);
- const privacyUrl =
- runtimeSnapshot.appPublic.legal.privacy_url ??
- (isSelfHosted ? null : `${runtimeSnapshot.marketingEndpoint}/privacy`);
- if (!showLegalConsent) {
- return {termsUrl, privacyUrl, requirement: null};
- }
- return {termsUrl, privacyUrl, requirement: resolveLegalConsentRequirement(termsUrl, privacyUrl)};
-}
-
-interface RegistrationLegalConsentProps {
- checked: boolean;
- config: RegistrationLegalConsentConfig;
- onChange: (checked: boolean) => void;
-}
-
-function RegistrationLegalConsentLabel({config}: {config: RegistrationLegalConsentConfig}): ReactElement | null {
- if (config.requirement === 'terms_and_privacy' && config.termsUrl != null && config.privacyUrl != null) {
- return (
- <Trans>
- I agree to the{' '}
- <ExternalLink
- href={config.termsUrl}
- className={styles.policyLink}
- data-flx="auth.flow.registration-legal-consent.policy-link.terms"
- >
- Terms of service
- </ExternalLink>{' '}
- and{' '}
- <ExternalLink
- href={config.privacyUrl}
- className={styles.policyLink}
- data-flx="auth.flow.registration-legal-consent.policy-link.privacy"
- >
- Privacy policy
- </ExternalLink>
- </Trans>
- );
- }
- if (config.requirement === 'terms' && config.termsUrl != null) {
- return (
- <Trans>
- I agree to the{' '}
- <ExternalLink
- href={config.termsUrl}
- className={styles.policyLink}
- data-flx="auth.flow.registration-legal-consent.policy-link.terms-only"
- >
- Terms of service
- </ExternalLink>
- </Trans>
- );
- }
- if (config.requirement === 'privacy' && config.privacyUrl != null) {
- return (
- <Trans>
- I agree to the{' '}
- <ExternalLink
- href={config.privacyUrl}
- className={styles.policyLink}
- data-flx="auth.flow.registration-legal-consent.policy-link.privacy-only"
- >
- Privacy policy
- </ExternalLink>
- </Trans>
- );
- }
- return null;
-}
-
-export function RegistrationLegalConsent({checked, config, onChange}: RegistrationLegalConsentProps) {
- if (config.requirement == null) return null;
- return (
- <flx-auth-registration-legal-consent
- className={flxElementClassName(styles.consentRow)}
- data-flx="auth.flow.registration-legal-consent.consent-row"
- >
- <Checkbox
- checked={checked}
- onChange={onChange}
- data-flx="auth.flow.registration-legal-consent.checkbox.consent-change"
- >
- <span className={styles.consentLabel} data-flx="auth.flow.registration-legal-consent.consent-label">
- <RegistrationLegalConsentLabel
- config={config}
- data-flx="auth.flow.registration-legal-consent.registration-legal-consent-label"
- />
- </span>
- </Checkbox>
- </flx-auth-registration-legal-consent>
- );
-}
diff --git a/fluxer_app/src/features/auth/flow/RegistrationLegalNotice.tsx b/fluxer_app/src/features/auth/flow/RegistrationLegalNotice.tsx
new file mode 100644
index 000000000..ff5b93f2e
--- /dev/null
+++ b/fluxer_app/src/features/auth/flow/RegistrationLegalNotice.tsx
@@ -0,0 +1,118 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {ExternalLink} from '@app/features/app/components/shared/ExternalLink';
+import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore';
+import styles from '@app/features/auth/flow/AuthPageStyles.module.css';
+import DeveloperOptions from '@app/features/devtools/state/DeveloperOptions';
+import {Trans} from '@lingui/react/macro';
+import type {ReactNode} from 'react';
+
+type LegalConsentRequirement = 'terms' | 'privacy' | 'terms_and_privacy';
+
+export interface RegistrationLegalConsentConfig {
+ termsUrl: string | null;
+ privacyUrl: string | null;
+ requirement: LegalConsentRequirement | null;
+}
+
+function resolveLegalConsentRequirement(
+ termsUrl: string | null,
+ privacyUrl: string | null,
+): LegalConsentRequirement | null {
+ if (termsUrl != null && privacyUrl != null) {
+ return 'terms_and_privacy';
+ }
+ if (termsUrl != null) {
+ return 'terms';
+ }
+ if (privacyUrl != null) {
+ return 'privacy';
+ }
+ return null;
+}
+
+export function getRegistrationLegalConsentConfig(
+ runtimeSnapshot: RuntimeConfigSnapshot,
+ showLegalConsent = true,
+): RegistrationLegalConsentConfig {
+ const isSelfHosted = DeveloperOptions.selfHostedModeOverride || runtimeSnapshot.features.self_hosted;
+ const termsUrl =
+ runtimeSnapshot.appPublic.legal.terms_url ?? (isSelfHosted ? null : `${runtimeSnapshot.marketingEndpoint}/terms`);
+ const privacyUrl =
+ runtimeSnapshot.appPublic.legal.privacy_url ??
+ (isSelfHosted ? null : `${runtimeSnapshot.marketingEndpoint}/privacy`);
+ if (!showLegalConsent) {
+ return {termsUrl, privacyUrl, requirement: null};
+ }
+ return {termsUrl, privacyUrl, requirement: resolveLegalConsentRequirement(termsUrl, privacyUrl)};
+}
+
+function TermsLink({href, children}: {href: string; children?: ReactNode}) {
+ return (
+ <ExternalLink
+ href={href}
+ className={styles.policyLink}
+ data-flx="auth.flow.registration-legal-notice.policy-link.terms"
+ >
+ {children}
+ </ExternalLink>
+ );
+}
+
+function PrivacyLink({href, children}: {href: string; children?: ReactNode}) {
+ return (
+ <ExternalLink
+ href={href}
+ className={styles.policyLink}
+ data-flx="auth.flow.registration-legal-notice.policy-link.privacy"
+ >
+ {children}
+ </ExternalLink>
+ );
+}
+
+export function RegistrationLegalNotice({config}: {config: RegistrationLegalConsentConfig}) {
+ const {termsUrl, privacyUrl, requirement} = config;
+ let content: ReactNode = null;
+ if (requirement === 'terms_and_privacy' && termsUrl !== null && privacyUrl !== null) {
+ content = (
+ <Trans comment="Notice right above the Create account button. Creating the account accepts the terms of service. The privacy policy is only explained, people never agree to it.">
+ By creating an account, you agree to the{' '}
+ <TermsLink href={termsUrl} data-flx="auth.flow.registration-legal-notice.terms-link">
+ terms of service
+ </TermsLink>
+ . The{' '}
+ <PrivacyLink href={privacyUrl} data-flx="auth.flow.registration-legal-notice.privacy-link">
+ privacy policy
+ </PrivacyLink>{' '}
+ explains how we handle your data.
+ </Trans>
+ );
+ } else if (requirement === 'terms' && termsUrl !== null) {
+ content = (
+ <Trans comment="Notice right above the Create account button when the instance only has terms of service.">
+ By creating an account, you agree to the{' '}
+ <TermsLink href={termsUrl} data-flx="auth.flow.registration-legal-notice.terms-link--2">
+ terms of service
+ </TermsLink>
+ .
+ </Trans>
+ );
+ } else if (requirement === 'privacy' && privacyUrl !== null) {
+ content = (
+ <Trans comment="Notice right above the Create account button when the instance only has a privacy policy. It only informs, people never agree to it.">
+ The{' '}
+ <PrivacyLink href={privacyUrl} data-flx="auth.flow.registration-legal-notice.privacy-link--2">
+ privacy policy
+ </PrivacyLink>{' '}
+ explains how we handle your data.
+ </Trans>
+ );
+ }
+ if (content === null) return null;
+ return (
+ <p className={styles.legalNotice} dir="auto" data-flx="auth.flow.registration-legal-notice">
+ {content}
+ </p>
+ );
+}
diff --git a/fluxer_app/src/features/auth/flow/SubmitTooltip.tsx b/fluxer_app/src/features/auth/flow/SubmitTooltip.tsx
index 99aff5f89..c25ed2f21 100644
--- a/fluxer_app/src/features/auth/flow/SubmitTooltip.tsx
+++ b/fluxer_app/src/features/auth/flow/SubmitTooltip.tsx
@@ -8,18 +8,6 @@ import {msg} from '@lingui/core/macro';
import {useLingui} from '@lingui/react/macro';
import type {ReactNode} from 'react';
-const YOU_MUST_AGREE_TO_THE_TERMS_OF_SERVICE_DESCRIPTOR = msg({
- message: 'You must agree to the terms of service and privacy policy to create an account',
- comment: 'Registration submit-button tooltip explaining that ToS and privacy agreement is required to proceed.',
-});
-const YOU_MUST_AGREE_TO_THE_TERMS_DESCRIPTOR = msg({
- message: 'You must agree to the terms of service to create an account',
- comment: 'Registration submit-button tooltip explaining that terms agreement is required to proceed.',
-});
-const YOU_MUST_AGREE_TO_THE_PRIVACY_POLICY_DESCRIPTOR = msg({
- message: 'You must agree to the privacy policy to create an account',
- comment: 'Registration submit-button tooltip explaining that privacy policy agreement is required to proceed.',
-});
const PLEASE_FILL_OUT_THE_FOLLOWING_FIELDS_DESCRIPTOR = msg({
message: 'Fill out the following fields: {fieldList}',
comment:
@@ -31,34 +19,17 @@ export interface MissingField {
label: string;
}
-export type LegalConsentRequirement = 'terms' | 'privacy' | 'terms_and_privacy';
-
export interface SubmitTooltipProps {
children: ReactNode;
- consent: boolean;
- legalConsentRequirement?: LegalConsentRequirement;
missingFields?: Array<MissingField>;
}
-function getConsentRequiredDescriptor(requirement: LegalConsentRequirement): MessageDescriptor {
- if (requirement === 'terms') return YOU_MUST_AGREE_TO_THE_TERMS_DESCRIPTOR;
- if (requirement === 'privacy') return YOU_MUST_AGREE_TO_THE_PRIVACY_POLICY_DESCRIPTOR;
- return YOU_MUST_AGREE_TO_THE_TERMS_OF_SERVICE_DESCRIPTOR;
-}
const getMissingFieldsDescriptor = (fieldList: string): MessageDescriptor => ({
...PLEASE_FILL_OUT_THE_FOLLOWING_FIELDS_DESCRIPTOR,
values: {fieldList},
});
-function getTooltipContentDescriptor(
- consent: boolean,
- missingFields: Array<MissingField>,
- legalConsentRequirement: LegalConsentRequirement,
- locale: string,
-): MessageDescriptor | null {
- if (!consent) {
- return getConsentRequiredDescriptor(legalConsentRequirement);
- }
+function getTooltipContentDescriptor(missingFields: Array<MissingField>, locale: string): MessageDescriptor | null {
if (missingFields.length > 0) {
const fieldList = formatList(
missingFields.map((f) => f.label),
@@ -69,23 +40,13 @@ function getTooltipContentDescriptor(
return null;
}
-export function shouldDisableSubmit(consent: boolean, missingFields: Array<MissingField>): boolean {
- return !consent || missingFields.length > 0;
+export function shouldDisableSubmit(missingFields: Array<MissingField>): boolean {
+ return missingFields.length > 0;
}
-export function SubmitTooltip({
- children,
- consent,
- legalConsentRequirement = 'terms_and_privacy',
- missingFields = [],
-}: SubmitTooltipProps) {
+export function SubmitTooltip({children, missingFields = []}: SubmitTooltipProps) {
const {i18n} = useLingui();
- const tooltipContentDescriptor = getTooltipContentDescriptor(
- consent,
- missingFields,
- legalConsentRequirement,
- i18n.locale,
- );
+ const tooltipContentDescriptor = getTooltipContentDescriptor(missingFields, i18n.locale);
const tooltipContent = tooltipContentDescriptor ? i18n._(tooltipContentDescriptor) : null;
if (!tooltipContent) {
return <>{children}</>;
diff --git a/fluxer_app/src/features/auth/state/AuthRegisterDraftContext.ts b/fluxer_app/src/features/auth/state/AuthRegisterDraftContext.ts
index 59af62f18..1d72f6e24 100644
--- a/fluxer_app/src/features/auth/state/AuthRegisterDraftContext.ts
+++ b/fluxer_app/src/features/auth/state/AuthRegisterDraftContext.ts
@@ -7,7 +7,6 @@ export interface AuthRegisterFormDraft {
selectedMonth: string;
selectedDay: string;
selectedYear: string;
- consent: boolean;
}
export const EMPTY_AUTH_REGISTER_FORM_DRAFT: AuthRegisterFormDraft = {
@@ -15,7 +14,6 @@ export const EMPTY_AUTH_REGISTER_FORM_DRAFT: AuthRegisterFormDraft = {
selectedMonth: '',
selectedDay: '',
selectedYear: '',
- consent: false,
};
interface AuthRegisterDraftContextType {