Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Tweak signup flow terms and conditions and skip the step by default for self-hosted environments (#2466)
Leendert de Borstf50c1143bb6b
diff --git a/apps/web/entrypoint.sh b/apps/web/entrypoint.shindex 718807570..d5468822a 100755--- a/apps/web/entrypoint.sh+++ b/apps/web/entrypoint.sh@@ -77,5 +77,13 @@ elsesed -i "s|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\"|\"PublicRegistrationEnabled\": \"$PUBLIC_REGISTRATION_ENABLED\",\n \"DeploymentMode\": \"$DEPLOYMENT_MODE\"|g" /usr/share/nginx/html/appsettings.jsonfi+# Update the terms URL new users must accept at registration. Empty (the default) skips the terms step.+TERMS_URL=${TERMS_URL:-}+if grep -q "TermsUrl" /usr/share/nginx/html/appsettings.json; then+ sed -i "s|\"TermsUrl\": \".*\"|\"TermsUrl\": \"$TERMS_URL\"|g" /usr/share/nginx/html/appsettings.json+else+ sed -i "s|\"DeploymentMode\": \"$DEPLOYMENT_MODE\"|\"DeploymentMode\": \"$DEPLOYMENT_MODE\",\n \"TermsUrl\": \"$TERMS_URL\"|g" /usr/share/nginx/html/appsettings.json+fi+# Start the applicationnginx -g "daemon off;"diff --git a/apps/web/public/appsettings.json b/apps/web/public/appsettings.jsonindex 39b9960eb..eba6a82f9 100644--- a/apps/web/public/appsettings.json+++ b/apps/web/public/appsettings.json@@ -2,7 +2,8 @@"ApiUrl": "http://localhost:5100","PrivateEmailDomains": ["example.tld", "example2.tld", "aliasvault.net", "disabled.tld"],"HiddenPrivateEmailDomains": ["disabled.tld"],- "SupportEmail": "[email protected]","PublicRegistrationEnabled": "true",- "DeploymentMode": ""+ "DeploymentMode": "",+ "SupportEmail": "[email protected]",+ "TermsUrl": ""}diff --git a/apps/web/src/components/auth/AuthPreferences.tsx b/apps/web/src/components/auth/AuthPreferences.tsxnew file mode 100644index 000000000..468a39125--- /dev/null+++ b/apps/web/src/components/auth/AuthPreferences.tsx@@ -0,0 +1,26 @@+import React from 'react';+import { useTranslation } from 'react-i18next';++import LanguageSwitcher from '@/components/auth/LanguageSwitcher';+import Icon from '@/components/shared/Icon';+import { useTheme } from '@/context/ThemeContext';++/**+ * Theme toggle and language selector shown on the auth pages.+ */+const AuthPreferences: React.FC = () => {+ const { t } = useTranslation();+ const { isDarkMode, toggleTheme } = useTheme();+ const label = isDarkMode ? t('web.topMenu.enableLightMode') : t('web.topMenu.enableDarkMode');++ return (+ <div className="flex items-center gap-1">+ <button type="button" id="auth-theme-toggle" onClick={toggleTheme} title={label} aria-label={label} className="p-2 rounded-md text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500">+ <Icon name={isDarkMode ? 'sun' : 'moon'} className="w-5 h-5" />+ </button>+ <LanguageSwitcher />+ </div>+ );+};++export default AuthPreferences;diff --git a/apps/web/src/components/auth/setup/SetupSteps.tsx b/apps/web/src/components/auth/setup/SetupSteps.tsxindex cb81f3d6c..83065b0e4 100644--- a/apps/web/src/components/auth/setup/SetupSteps.tsx+++ b/apps/web/src/components/auth/setup/SetupSteps.tsx@@ -2,10 +2,11 @@ import { apiErrorMessage } from '@aliasvault/client/api/errors/ApiErrorMessage';import { ApiRequestError } from '@aliasvault/client/api/errors/ApiRequestError';import { MIN_ACCEPTED_PASSWORD_LENGTH } from '@aliasvault/client/utilities/PasswordStrength';import React, { useEffect, useRef, useState } from 'react';-import { useTranslation } from 'react-i18next';+import { Trans, useTranslation } from 'react-i18next';import GlobalNotificationDisplay from '@/components/alerts/GlobalNotificationDisplay';import PasswordInputField from '@/components/auth/PasswordInputField';+import TermsModal from '@/components/auth/setup/TermsModal';import EditFormRow from '@/components/forms/EditFormRow';import FormLabel from '@/components/shared/FormLabel';import PasswordStrengthIndicator from '@/components/shared/PasswordStrengthIndicator';@@ -47,31 +48,7 @@ const StepFrame: React.FC<{ isLoading: boolean; children: React.ReactNode }> = ();/**- * Step 1: read and accept the terms.- */-export const TermsAndConditionsStep: React.FC<{ agreedToTerms: boolean; onAgreedToTermsChange: (agreed: boolean) => void }> = ({ agreedToTerms, onAgreedToTermsChange }) => {- const { t } = useTranslation();- const isLoading = useStepLoading();-- return (- <StepFrame isLoading={isLoading}>- <div className="bg-white dark:bg-gray-800 rounded-lg shadow-lg lg:shadow-none p-6">- <p className="text-sm text-gray-600 dark:text-gray-400 mb-4">{t('auth.setup.termsStep.pleaseReadAndAgree')}</p>- <div className="bg-gray-100 dark:bg-gray-700 rounded-lg p-4 mb-8 h-80 overflow-y-auto">- <h3 className="text-lg font-semibold text-gray-900 dark:text-white mb-2">{t('auth.register.termsAndConditionsLink')}</h3>- <p className="text-sm text-gray-600 dark:text-gray-400 whitespace-pre-line">{t('auth.setup.termsStep.termsContent')}</p>- </div>- <div className="flex items-center">- <input type="checkbox" id="agreeTerms" checked={agreedToTerms} onChange={e => onAgreedToTermsChange(e.target.checked)} className="mr-2" />- <label htmlFor="agreeTerms" className="text-sm font-bold text-gray-600 dark:text-gray-400">{t('auth.setup.termsStep.agreementCheckboxLabel')}</label>- </div>- </div>- </StepFrame>- );-};--/**- * Step 2: pick a username.+ * Step 1: pick a username.*/export const UsernameStep: React.FC<{ defaultUsername: string; inviteCode?: string; onUsernameChange: (username: string) => void }> = ({ defaultUsername, inviteCode, onUsernameChange }) => {const { t } = useTranslation();@@ -144,7 +121,7 @@ export const UsernameStep: React.FC<{ defaultUsername: string; inviteCode?: stri<img className="h-10 w-10" src="/img/logo.svg" alt={t('auth.setup.usernameStep.assistantAvatarAlt')} /></div><div className="ml-3 bg-blue-100 dark:bg-blue-900 rounded-lg p-3">- <p className="text-sm text-gray-900 dark:text-white">{t('auth.setup.usernameStep.greatNowLetsSetupUsername')}</p>+ <p className="text-sm text-gray-900 dark:text-white">{t('auth.setup.usernameStep.welcomeMessage')}</p><p className="text-sm text-gray-900 dark:text-white mt-3">{t('auth.setup.usernameStep.enterUsernameInstructions')}</p><p className="text-sm text-gray-900 dark:text-white mt-3 font-semibold">{t('auth.setup.usernameStep.rememberUsernameNote')}</p></div>@@ -170,15 +147,18 @@ export const UsernameStep: React.FC<{ defaultUsername: string; inviteCode?: stri};/**- * Step 3: choose the master password.+ * Step 2: choose the master password.*/-export const PasswordStep: React.FC<{ onPasswordChange: (password: string) => void }> = ({ onPasswordChange }) => {+export const PasswordStep: React.FC<{ termsUrl: string; agreedToTerms: boolean; onAgreedToTermsChange: (agreed: boolean) => void; onPasswordChange: (password: string) => void }> = ({ termsUrl, agreedToTerms, onAgreedToTermsChange, onPasswordChange }) => {const { t } = useTranslation();+ const [showTerms, setShowTerms] = useState(false);const isLoading = useStepLoading();const [password, setPassword] = useState('');const [confirmPassword, setConfirmPassword] = useState('');const [errorMessage, setErrorMessage] = useState('');const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);+ // The debounced check reads the confirmation at fire time, so a quickly filled confirm field is not validated as empty.+ const confirmPasswordRef = useRef('');// Autofocus the password input.useEffect(() => {@@ -219,7 +199,7 @@ export const PasswordStep: React.FC<{ onPasswordChange: (password: string) => voif (debounceTimer.current) {clearTimeout(debounceTimer.current);}- debounceTimer.current = setTimeout(() => validate(value, confirmPassword), PASSWORD_DEBOUNCE_MS);+ debounceTimer.current = setTimeout(() => validate(value, confirmPasswordRef.current), PASSWORD_DEBOUNCE_MS);};/**@@ -227,6 +207,7 @@ export const PasswordStep: React.FC<{ onPasswordChange: (password: string) => vo*/const onConfirmInput = (value: string): void => {setConfirmPassword(value);+ confirmPasswordRef.current = value;validate(password, value);};@@ -267,13 +248,22 @@ export const PasswordStep: React.FC<{ onPasswordChange: (password: string) => vo</div>{errorMessage.length > 0 && <div className="mt-2 text-sm text-red-600 dark:text-red-400">{errorMessage}</div>}</div>+ {termsUrl && (+ <div className="flex items-start">+ <input type="checkbox" id="agreeTerms" checked={agreedToTerms} onChange={e => onAgreedToTermsChange(e.target.checked)} className="mt-0.5 mr-2" />+ <label htmlFor="agreeTerms" className="text-sm text-gray-600 dark:text-gray-400">+ <Trans i18nKey="auth.setup.termsAgreementLabel" components={{ termsLink: <button type="button" onClick={() => setShowTerms(true)} className="text-primary-700 dark:text-primary-400 hover:underline" /> }} />+ </label>+ </div>+ )}</div>+ {showTerms && <TermsModal termsUrl={termsUrl} onClose={() => setShowTerms(false)} />}</StepFrame>);};/**- * Step 4: create the account.+ * Step 3: create the account.*/export const CreatingStep: React.FC<{ username: string; password: string; inviteCode?: string; onDone: () => void }> = ({ username, password, inviteCode, onDone }) => {const { t } = useTranslation();diff --git a/apps/web/src/components/auth/setup/TermsModal.tsx b/apps/web/src/components/auth/setup/TermsModal.tsxnew file mode 100644index 000000000..8efd7702a--- /dev/null+++ b/apps/web/src/components/auth/setup/TermsModal.tsx@@ -0,0 +1,86 @@+import React, { useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';++import Icon from '@/components/shared/Icon';+import Markdown from '@/components/shared/Markdown';+import Modal from '@/components/shared/Modal';++/**+ * The terms in a dialog, loaded from the Markdown version at `<termsUrl>.md`. Falls back to a link when that cannot be fetched.+ */+const TermsModal: React.FC<{ termsUrl: string; onClose: () => void }> = ({ termsUrl, onClose }) => {+ const { t } = useTranslation();+ const [terms, setTerms] = useState<string | null>(null);+ const [termsFailed, setTermsFailed] = useState(false);++ useEffect(() => {+ let cancelled = false;+ fetch(`${termsUrl}.md`)+ .then(response => {+ if (!response.ok) {+ throw new Error(`HTTP ${response.status}`);+ }+ return response.text();+ })+ // The dialog has its own title, so the document's leading H1 is dropped.+ .then(text => !cancelled && setTerms(text.replace(/^\s*#\s[^\n]*\n/, '')))+ .catch((error: unknown) => {+ console.warn('Could not load the terms:', error);+ if (!cancelled) {+ setTermsFailed(true);+ }+ });+ return (): void => {+ cancelled = true;+ };+ }, [termsUrl]);++ useEffect(() => {+ /**+ * Escape closes the dialog.+ */+ const onKeyDown = (e: KeyboardEvent): void => {+ if (e.key === 'Escape') {+ e.stopPropagation();+ onClose();+ }+ };+ window.addEventListener('keydown', onKeyDown, true);+ return (): void => window.removeEventListener('keydown', onKeyDown, true);+ }, [onClose]);++ return (+ <Modal id="terms-modal" zIndexClass="z-[1000]" panelClassName="w-full max-w-2xl flex flex-col max-h-[85vh]" onBackdropClick={onClose}>+ <div className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700">+ <h3 className="text-lg font-semibold text-gray-900 dark:text-white">{t('auth.register.termsAndConditionsLink')}</h3>+ <div className="flex items-center gap-3">+ <a href={termsUrl} target="_blank" rel="noopener noreferrer" title={t('auth.register.termsAndConditionsLink')} className="text-gray-500 hover:text-primary-700 dark:text-gray-400 dark:hover:text-primary-400">+ <Icon name="external-link" className="w-5 h-5" />+ </a>+ <button type="button" onClick={onClose} aria-label={t('common.close')} className="text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200">+ <Icon name="x" className="w-6 h-6" />+ </button>+ </div>+ </div>+ <div className="p-4 overflow-y-auto">+ {termsFailed ? (+ <a href={termsUrl} target="_blank" rel="noopener noreferrer" className="flex items-center gap-2 text-primary-700 dark:text-primary-400 hover:underline">+ {termsUrl}+ <Icon name="external-link" className="w-4 h-4" />+ </a>+ ) : terms === null ? (+ <p className="text-sm text-gray-600 dark:text-gray-400">{t('common.loading')}</p>+ ) : (+ <Markdown content={terms} />+ )}+ </div>+ <div className="p-4 border-t border-gray-200 dark:border-gray-700">+ <button type="button" onClick={onClose} className="w-full py-2 px-4 bg-primary-600 hover:bg-primary-700 text-white font-semibold rounded-lg">+ {t('common.close')}+ </button>+ </div>+ </Modal>+ );+};++export default TermsModal;diff --git a/apps/web/src/components/shared/Markdown.tsx b/apps/web/src/components/shared/Markdown.tsxnew file mode 100644index 000000000..e0b36fc6a--- /dev/null+++ b/apps/web/src/components/shared/Markdown.tsx@@ -0,0 +1,101 @@+import React from 'react';++/*+ * Markdown renderer for remote documents (e.g. the registration terms and conditions).+ */++/** A link target we are willing to render. */+const SAFE_HREF = /^(https?:|mailto:)/i;++/** Inline tokens: link, bold, italic. */+const INLINE = /\[([^\]]+)\]\(([^)\s]+)\)|\*\*(.+?)\*\*|\*(.+?)\*/g;++/**+ * Render the inline markup of one line of text.+ */+function renderInline(text: string, keyPrefix: string): React.ReactNode[] {+ const nodes: React.ReactNode[] = [];+ let last = 0;+ for (const match of text.matchAll(INLINE)) {+ const index = match.index ?? 0;+ if (index > last) {+ nodes.push(text.slice(last, index));+ }+ const key = `${keyPrefix}-${index}`;+ const [whole, linkText, href, bold, italic] = match;+ if (linkText !== undefined) {+ nodes.push(SAFE_HREF.test(href) ? <a key={key} href={href} target="_blank" rel="noopener noreferrer" className="text-primary-700 dark:text-primary-400 hover:underline">{linkText}</a> : linkText);+ } else if (bold !== undefined) {+ nodes.push(<strong key={key} className="font-semibold text-gray-900 dark:text-white">{bold}</strong>);+ } else if (italic !== undefined) {+ nodes.push(<em key={key}>{italic}</em>);+ } else {+ nodes.push(whole);+ }+ last = index + whole.length;+ }+ if (last < text.length) {+ nodes.push(text.slice(last));+ }+ return nodes;+}++/**+ * Render a Markdown document as styled React elements.+ */+const Markdown: React.FC<{ content: string }> = ({ content }) => {+ const blocks: React.ReactNode[] = [];+ let paragraph: string[] = [];+ let list: string[] = [];++ /**+ * Close the open paragraph or list, if any.+ */+ const flush = (): void => {+ const key = `b${blocks.length}`;+ if (paragraph.length > 0) {+ blocks.push(<p key={key} className="mb-3">{renderInline(paragraph.join(' '), key)}</p>);+ paragraph = [];+ }+ if (list.length > 0) {+ blocks.push(<ul key={key} className="mb-3 ml-5 list-disc space-y-1">{list.map((item, i) => <li key={i}>{renderInline(item, `${key}-${i}`)}</li>)}</ul>);+ list = [];+ }+ };++ for (const rawLine of content.split(/\r?\n/)) {+ const line = rawLine.trim();+ const heading = /^(#{1,6})\s+(.*)$/.exec(line);+ const listItem = /^[-*]\s+(.*)$/.exec(line);+ if (line.length === 0 || /^-{3,}$/.test(line)) {+ flush();+ } else if (heading) {+ flush();+ const key = `b${blocks.length}`;+ const level = heading[1].length;+ const text = renderInline(heading[2], key);+ if (level === 1) {+ blocks.push(<h3 key={key} className="mb-2 text-lg font-semibold text-gray-900 dark:text-white">{text}</h3>);+ } else if (level === 2) {+ blocks.push(<h4 key={key} className="mt-4 mb-2 font-semibold text-gray-900 dark:text-white">{text}</h4>);+ } else {+ blocks.push(<h5 key={key} className="mt-3 mb-1 font-semibold text-gray-900 dark:text-white">{text}</h5>);+ }+ } else if (listItem) {+ if (paragraph.length > 0) {+ flush();+ }+ list.push(listItem[1]);+ } else {+ if (list.length > 0) {+ flush();+ }+ paragraph.push(line);+ }+ }+ flush();++ return <div className="text-sm text-gray-600 dark:text-gray-400">{blocks}</div>;+};++export default Markdown;diff --git a/apps/web/src/config/AppConfig.ts b/apps/web/src/config/AppConfig.tsindex 42acdb6e9..41e2fe91e 100644--- a/apps/web/src/config/AppConfig.ts+++ b/apps/web/src/config/AppConfig.ts@@ -17,20 +17,20 @@ type AppSettingsFile = {SupportEmail?: string;PublicRegistrationEnabled?: string | boolean;DeploymentMode?: string;+ TermsUrl?: string;};/*** The resolved configuration.*/export type AppConfig = {- /** Base URL of the API, without trailing slash. */apiUrl: string;privateEmailDomains: string[];hiddenPrivateEmailDomains: string[];supportEmail: string;publicRegistrationEnabled: boolean;- /** How this instance was deployed (install / build / aio), shown in the footer. Empty when unknown. */deploymentMode: string;+ termsUrl: string;};let current: AppConfig | null = null;@@ -74,6 +74,7 @@ export async function loadAppConfig(): Promise<AppConfig> {supportEmail: file.SupportEmail ?? '',publicRegistrationEnabled: String(file.PublicRegistrationEnabled ?? 'true').toLowerCase() === 'true',deploymentMode: file.DeploymentMode ?? '',+ termsUrl: (file.TermsUrl ?? '').trim(),};await getPlatform().storage.set(StorageKeys.API_URL, apiUrl);diff --git a/apps/web/src/layouts/AuthLayout.tsx b/apps/web/src/layouts/AuthLayout.tsxindex 90e56c61c..2853a355b 100644--- a/apps/web/src/layouts/AuthLayout.tsx+++ b/apps/web/src/layouts/AuthLayout.tsx@@ -2,7 +2,7 @@ import React from 'react';import { Outlet, useLocation } from 'react-router-dom';import GlobalNotificationDisplay from '@/components/alerts/GlobalNotificationDisplay';-import LanguageSwitcher from '@/components/auth/LanguageSwitcher';+import AuthPreferences from '@/components/auth/AuthPreferences';import Logo from '@/components/auth/Logo';/**@@ -13,13 +13,13 @@ const AuthLayout: React.FC = () => {const path = location.pathname.toLowerCase();// Show on login, forgot password and register, not during setup or unlock.- const showLanguageSwitcher = path.includes('/user/login') || path.includes('/user/forgot-password') || path.endsWith('/');+ const showPreferences = path.includes('/user/login') || path.includes('/user/forgot-password') || path.endsWith('/');return (<div className="flex flex-col items-center justify-center px-6 pt-8 pb-8 mx-auto md:h-screen pt:mt-0 relative">- {showLanguageSwitcher && (+ {showPreferences && (<div className="absolute top-4 right-4 z-10">- <LanguageSwitcher />+ <AuthPreferences /></div>)}<Logo />diff --git a/apps/web/src/pages/auth/Logout.tsx b/apps/web/src/pages/auth/Logout.tsxindex d0419ddd3..ab7009107 100644--- a/apps/web/src/pages/auth/Logout.tsx+++ b/apps/web/src/pages/auth/Logout.tsx@@ -26,13 +26,13 @@ const Logout: React.FC = () => {hasStarted.current = true;/**- * Revoke the tokens and redirect to the login page.+ * Revoke the tokens and redirect to the start page.*/const run = async (): Promise<void> => {await auth.logout({ userInitiated: true });notifications.clearMessages();await delay(500);- navigate('/user/login', { replace: true });+ navigate('/user/start', { replace: true });};void run();}, [auth, notifications, navigate]);diff --git a/apps/web/src/pages/auth/Setup.tsx b/apps/web/src/pages/auth/Setup.tsxindex f5999c540..2d4efee86 100644--- a/apps/web/src/pages/auth/Setup.tsx+++ b/apps/web/src/pages/auth/Setup.tsx@@ -5,9 +5,9 @@ import { useTranslation } from 'react-i18next';import { Link, useNavigate, useSearchParams } from 'react-router-dom';import AlertMessageError from '@/components/alerts/AlertMessageError';-import LanguageSwitcher from '@/components/auth/LanguageSwitcher';+import AuthPreferences from '@/components/auth/AuthPreferences';import Logo from '@/components/auth/Logo';-import { CreatingStep, PasswordStep, TermsAndConditionsStep, UsernameStep } from '@/components/auth/setup/SetupSteps';+import { CreatingStep, PasswordStep, UsernameStep } from '@/components/auth/setup/SetupSteps';import { ButtonLabel } from '@/components/shared/Button';import Icon from '@/components/shared/Icon';import { getAppConfig } from '@/config/AppConfig';@@ -15,12 +15,12 @@ import { useWebApi } from '@/context/WebApiContext';import { usePageTitle } from '@/hooks/usePageTitle';/** The wizard steps, in order. */-const STEPS = ['terms', 'username', 'password', 'creating'] as const;+const STEPS = ['username', 'password', 'creating'] as const;type SetupStep = typeof STEPS[number];/**- * The create vault wizard: terms, username, password, then registration. When public registration is disabled, the wizard- * only opens from a valid admin invite link (`?invite=<code>`).+ * The create vault wizard: username, password (plus the terms checkbox when a terms URL is configured), then registration.+ * When public registration is disabled, the wizard only opens from a valid admin invite link (`?invite=<code>`).*/const Setup: React.FC = () => {const { t } = useTranslation();@@ -29,10 +29,11 @@ const Setup: React.FC = () => {const [searchParams] = useSearchParams();const requiresInvite = !getAppConfig().publicRegistrationEnabled;const inviteCode = requiresInvite ? (searchParams.get('invite') ?? '').trim() : '';+ const termsUrl = getAppConfig().termsUrl;usePageTitle(t('auth.setup.setupStepTitle'));- const [step, setStep] = useState<SetupStep>('terms');+ const [step, setStep] = useState<SetupStep>('username');const [isCheckingInvite, setIsCheckingInvite] = useState(requiresInvite && inviteCode.length > 0);const [isInviteRejected, setIsInviteRejected] = useState(false);const [inviteError, setInviteError] = useState('');@@ -57,7 +58,8 @@ const Setup: React.FC = () => {}, [inviteCode, requiresInvite, t, webApi]);const isBlocked = isCheckingInvite || inviteError.length > 0;- const isNextEnabled = step === 'terms' ? agreedToTerms : step === 'username' ? username.trim().length > 0 : step === 'password' ? password.trim().length > 0 : false;+ const isPasswordStepComplete = password.trim().length > 0 && (!termsUrl || agreedToTerms);+ const isNextEnabled = step === 'username' ? username.trim().length > 0 : step === 'password' ? isPasswordStepComplete : false;const stepIndex = STEPS.indexOf(step);const progressPercentage = Math.floor(stepIndex * 100 / (STEPS.length - 1));@@ -66,7 +68,6 @@ const Setup: React.FC = () => {*/const stepTitle = (): string => {switch (step) {- case 'terms': return t('auth.setup.termsAndConditionsStepTitle');case 'username': return t('auth.setup.usernameStepTitle');case 'password': return t('auth.setup.passwordStepTitle');default: return t('auth.setup.creatingStepTitle');@@ -111,7 +112,7 @@ const Setup: React.FC = () => {return (<div className="min-h-screen bg-gray-100 dark:bg-gray-900 flex flex-col lg:items-center lg:justify-center"><div className="absolute top-4 right-4 z-10 mt-16 lg:mt-0 hidden lg:block">- <LanguageSwitcher />+ <AuthPreferences /></div><div className="w-full mx-auto lg:max-w-xl lg:bg-white lg:dark:bg-gray-800 lg:shadow-xl lg:rounded-lg lg:overflow-hidden flex flex-col"><div className="flex flex-col flex-grow">@@ -145,16 +146,15 @@ const Setup: React.FC = () => {</div>)}{inviteError.length > 0 && <AlertMessageError message={inviteError} />}- {!isBlocked && step === 'terms' && <TermsAndConditionsStep agreedToTerms={agreedToTerms} onAgreedToTermsChange={setAgreedToTerms} />}- {step === 'username' && <UsernameStep defaultUsername={username} inviteCode={inviteCode || undefined} onUsernameChange={setUsername} />}- {step === 'password' && <PasswordStep onPasswordChange={setPassword} />}+ {!isBlocked && step === 'username' && <UsernameStep defaultUsername={username} inviteCode={inviteCode || undefined} onUsernameChange={setUsername} />}+ {step === 'password' && <PasswordStep termsUrl={termsUrl} agreedToTerms={agreedToTerms} onAgreedToTermsChange={setAgreedToTerms} onPasswordChange={setPassword} />}{step === 'creating' && <CreatingStep username={username} password={password} inviteCode={inviteCode || undefined} onDone={onRegistered} />}<button type="submit" className="hidden" /></form></div><div className="fixed lg:relative bottom-0 left-0 right-0 p-4 bg-gray-100 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-700 lg:bg-transparent lg:dark:bg-transparent lg:border-0">{step === 'password' && password.trim().length > 0 ? (- <button type="button" onClick={goNext} className="w-full py-3 px-4 bg-green-600 hover:bg-green-700 text-white font-semibold rounded-lg transition duration-300 ease-in-out">+ <button type="button" onClick={goNext} disabled={!isNextEnabled} className={`w-full py-3 px-4 bg-green-600 hover:bg-green-700 text-white font-semibold rounded-lg transition duration-300 ease-in-out ${isNextEnabled ? '' : 'opacity-50 cursor-not-allowed'}`}>{t('auth.setup.createAccountButton')}</button>) : step !== 'creating' && !isBlocked && (diff --git a/apps/web/src/pages/auth/Start.tsx b/apps/web/src/pages/auth/Start.tsxindex 166324930..7f0950d8e 100644--- a/apps/web/src/pages/auth/Start.tsx+++ b/apps/web/src/pages/auth/Start.tsx@@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';import { Link, useNavigate } from 'react-router-dom';import MessageInfo from '@/components/alerts/MessageInfo';-import LanguageSwitcher from '@/components/auth/LanguageSwitcher';+import AuthPreferences from '@/components/auth/AuthPreferences';import Logo from '@/components/auth/Logo';import FooterLogin from '@/components/layout/FooterLogin';import { getAppConfig } from '@/config/AppConfig';@@ -39,7 +39,7 @@ const Start: React.FC = () => {<><div className="relative"><div className="absolute top-4 right-4 z-10">- <LanguageSwitcher />+ <AuthPreferences /></div></div>diff --git a/apps/web/tests/e2e/01-registration.spec.ts b/apps/web/tests/e2e/01-registration.spec.tsindex b9c3b65bb..c94579568 100644--- a/apps/web/tests/e2e/01-registration.spec.ts+++ b/apps/web/tests/e2e/01-registration.spec.ts@@ -15,11 +15,6 @@ test.describe('1. Registration', () => {await expect(page).toHaveURL(/\/user\/setup$/);});- await test.step('accept the terms', async () => {- await page.locator('#agreeTerms').check();- await continueButton.click();- });-await test.step('choose a username, checked against the server', async () => {await page.locator('#username').fill(credentials.username);await expect(page.getByText('Username is available')).toBeVisible();@@ -29,6 +24,7 @@ test.describe('1. Registration', () => {await test.step('set the master password and create the account', async () => {await page.locator('#password').fill(credentials.password);await page.locator('#confirmPassword').fill(credentials.password);+ await page.locator('#agreeTerms').check();await page.getByRole('button', { name: 'Create Account' }).click();});@@ -85,8 +81,6 @@ test.describe('1. Registration with public registration disabled', () => {await test.step('open the invite link', async () => {await page.goto(`/user/setup?invite=${encodeURIComponent(inviteCode)}`);- await page.locator('#agreeTerms').check();- await continueButton.click();});await test.step('choose a username, checked against the server with the invite', async () => {@@ -98,6 +92,7 @@ test.describe('1. Registration with public registration disabled', () => {await test.step('set the master password and create the account', async () => {await page.locator('#password').fill(credentials.password);await page.locator('#confirmPassword').fill(credentials.password);+ await page.locator('#agreeTerms').check();await page.getByRole('button', { name: 'Create Account' }).click();await expect(page).toHaveURL(/\/welcome$/);});diff --git a/apps/web/tests/e2e/06-settings.spec.ts b/apps/web/tests/e2e/06-settings.spec.tsindex 2e3ce0759..ab679bd30 100644--- a/apps/web/tests/e2e/06-settings.spec.ts+++ b/apps/web/tests/e2e/06-settings.spec.ts@@ -34,7 +34,7 @@ test.describe('6. Settings', () => {await test.step('a browser without local preferences takes the language from the vault', async () => {await page.goto('/user/logout');- await expect(page).toHaveURL(/\/user\/login$/);+ await expect(page).toHaveURL(/\/user\/start$/);await page.evaluate(() => localStorage.clear());await app.login(testUser.username, testUser.password);await expect(emailsLink('E-mails')).toBeVisible();diff --git a/apps/web/tests/e2e/08-two-factor.spec.ts b/apps/web/tests/e2e/08-two-factor.spec.tsindex b6663a8a5..9b21e0e99 100644--- a/apps/web/tests/e2e/08-two-factor.spec.ts+++ b/apps/web/tests/e2e/08-two-factor.spec.ts@@ -51,6 +51,7 @@ async function enableTwoFactor(app: WebApp): Promise<TwoFactorSetup> {*/async function loginUntilTwoFactor(app: WebApp, username: string, password: string): Promise<void> {await app.logout();+ await app.page.getByRole('link', { name: 'Log in with existing account' }).click();await app.submitLogin(username, password);await expect(app.page.locator('#two-factor-code')).toBeVisible();}diff --git a/apps/web/tests/fixtures/WebApp.ts b/apps/web/tests/fixtures/WebApp.tsindex b400b7b48..4b56339f7 100644--- a/apps/web/tests/fixtures/WebApp.ts+++ b/apps/web/tests/fixtures/WebApp.ts@@ -18,13 +18,13 @@ export class WebApp {}/**- * Log out via the account popover and wait for the login page.+ * Log out via the account popover and wait for the start page.*/public async logout(): Promise<void> {await this.page.locator('#userMenuButton').click();await this.page.locator('#userMenuLogoutButton').click();await this.page.locator('#confirmButton').click();- await expect(this.page).toHaveURL(/\/user\/login$/);+ await expect(this.page).toHaveURL(/\/user\/start$/);}/**diff --git a/apps/web/tests/fixtures/fixtures.ts b/apps/web/tests/fixtures/fixtures.tsindex 218085436..af87f3e4b 100644--- a/apps/web/tests/fixtures/fixtures.ts+++ b/apps/web/tests/fixtures/fixtures.ts@@ -52,6 +52,7 @@ export const test = base.extend<TestFixtures>({SupportEmail: '[email protected]',PublicRegistrationEnabled: String(publicRegistrationEnabled),DeploymentMode: 'e2e',+ TermsUrl: 'https://example.tld/terms',}),}));if (!publicRegistrationEnabled) {diff --git a/core/i18n/hints.json b/core/i18n/hints.jsonindex c551964c4..cb4ef10ad 100644--- a/core/i18n/hints.json+++ b/core/i18n/hints.json@@ -44,17 +44,14 @@"auth.setup.passwordStep.welcomeMessage": "Assistant welcome message for password setup step","auth.setup.passwordStepTitle": "Title for the password creation step","auth.setup.setupStepTitle": "Default setup step title",- "auth.setup.termsAndConditionsStepTitle": "Title for the terms and conditions step",- "auth.setup.termsStep.agreementCheckboxLabel": "Label for the agreement checkbox",- "auth.setup.termsStep.pleaseReadAndAgree": "Instructions to read and agree to terms",- "auth.setup.termsStep.termsContent": "Full terms and conditions content",- "auth.setup.usernameStep.assistantAvatarAlt": "Alt text for assistant avatar image",+ "auth.setup.termsAgreementLabel": "Checkbox label at account creation; the text inside <termsLink> opens the terms",+ "auth.setup.usernameStep.assistantAvatarAlt": "Alt text for assistant avatar image","auth.setup.usernameStep.enterUsernameInstructions": "Instructions for entering username",- "auth.setup.usernameStep.greatNowLetsSetupUsername": "Assistant message about setting up username","auth.setup.usernameStep.rememberUsernameNote": "Important note about remembering username","auth.setup.usernameStep.serverCommunicationError": "Error message for server communication issues","auth.setup.usernameStep.usernamePlaceholder": "Placeholder text for username input","auth.setup.usernameStep.validatingUsernameMessage": "Message shown while validating username",+ "auth.setup.usernameStep.welcomeMessage": "Assistant greeting on the first step of account creation","auth.setup.usernameStepTitle": "Title for the username selection step","auth.start.httpsWarningMessage": "Message explaining why HTTPS is required","auth.start.httpsWarningTitle": "Title for HTTPS warning banner",diff --git a/core/i18n/locales/en.json b/core/i18n/locales/en.jsonindex 74d682078..72a3ebdff 100644--- a/core/i18n/locales/en.json+++ b/core/i18n/locales/en.json@@ -165,20 +165,15 @@"registrationDisabledMessage": "New accounts can only be created with an invite link. Ask the server administrator for an invite.","registrationDisabledTitle": "User registration is disabled","setupStepTitle": "Setup",- "termsAndConditionsStepTitle": "Using AliasVault",- "termsStep": {- "agreementCheckboxLabel": "I have read and agree to the Terms and Conditions",- "pleaseReadAndAgree": "Please read and agree to the following terms and conditions before proceeding.",- "termsContent": "AliasVault is designed to enhance your online security and protect your privacy. With AliasVault, you can create unique identities and email aliases for your various online accounts, helping you maintain control over your personal information and reduce the risk of identity theft.\n\nBy using AliasVault, you agree to the following terms:\n\n1. You will not use AliasVault for any illegal purposes, including but not limited to fraud, identity theft, or impersonating real individuals.\n\n2. You are responsible for maintaining the confidentiality of your account and any aliases created through AliasVault.\n\n3. AliasVault reserves the right to terminate your account if we suspect any misuse or violation of these terms.\n\n4. You understand that while AliasVault enhances your privacy, no system is completely foolproof, and you use the service at your own risk."- },+ "termsAgreementLabel": "I have read and agree to the <termsLink>Terms and Conditions</termsLink>","usernameStep": {"assistantAvatarAlt": "AliasVault Assistant","enterUsernameInstructions": "Please enter a username you'd like to use. This can be your email address or any unique name you prefer.",- "greatNowLetsSetupUsername": "Great! Now, let's set up your username for AliasVault.","rememberUsernameNote": "Remember: This is what you'll use to log in later, so make sure it's something you'll remember!","serverCommunicationError": "An error occurred during communication with the AliasVault server.","usernamePlaceholder": "Enter your desired username or email",- "validatingUsernameMessage": "Validating username..."+ "validatingUsernameMessage": "Validating username...",+ "welcomeMessage": "Welcome! Let's start by choosing a username for your account."},"usernameStepTitle": "Choose Username"},diff --git a/dockerfiles/all-in-one/s6-scripts/client/run b/dockerfiles/all-in-one/s6-scripts/client/runindex 0808955d1..4367587fd 100644--- a/dockerfiles/all-in-one/s6-scripts/client/run+++ b/dockerfiles/all-in-one/s6-scripts/client/run@@ -75,7 +75,8 @@ cat > /app/client/wwwroot/appsettings.json << EOF"HiddenPrivateEmailDomains": $hidden_json_array,"SupportEmail": "$SUPPORT_EMAIL","PublicRegistrationEnabled": "$PUBLIC_REGISTRATION_ENABLED",- "DeploymentMode": "${DEPLOYMENT_MODE:-aio-build}"+ "DeploymentMode": "${DEPLOYMENT_MODE:-aio-build}",+ "TermsUrl": "${TERMS_URL:-}"}EOF