Visible Terms and Privacy links on the auth screens (#317)
* feat: visible Terms/Privacy links on the auth screens Social-platform app reviews (TikTok explicitly) require both links to be reachable from the public site without logging in or opening a menu. * Cover the legal links with tests and tidy the layout The links are a compliance artifact an outside reviewer checks, but nothing asserted they exist. A refactor of this layout could drop the footer silently and the next platform submission would fail the same check that prompted the PR. A feature test asserts the shared prop reaches both guest screens and carries whatever the install configured, and a browser test asserts the two links actually render to a logged-out visitor. Declares legal on SharedData, so the props read through the interface rather than its index signature and the inline cast goes away. Adds rel="noopener noreferrer" to both anchors, matching every other target="_blank" in the codebase, and orders the imports the way eslint expects so the file lands clean rather than relying on --fix in CI. Drops the comment explaining why the links are there: that rationale belongs in the commit and the pull request, and the sibling comments in this file describe markup rather than justify decisions. * Reuse the legal sentence the register screen already had The register screen has shown "By continuing, you agree to our Terms of Service and Privacy Policy" in production for a long time, translated into all sixteen locales. Only the login screen was missing it, and the two URLs were hardcoded inside the translated string, so a self-hosted install could not point them at its own documents. So this keeps what already worked and changes only those two things. The markup moves into one component, which the login screen now renders as well. The translated sentence keeps its wording and its link labels; only the href becomes an i18n placeholder that the component fills from config. That is one line per locale, and no new translation keys. Reverting the footer out of AuthSplitLayout also stops the links from appearing on the workspace index and create screens, which reach that layout too and are seen after login rather than before it. The sentence no longer hides on a self-hosted install. It was hidden because it named TryPost's own documents; now that the URLs are configuration, an install that sets them wants it shown. A feature test covers the shared prop on both screens and the placeholder in every locale; a browser test covers the rendered sentence, since the links are a compliance artifact an outside reviewer checks and nothing guarded them. * Let the browser assertions do their own waiting The test hand-rolled a polling loop in injected JavaScript to wait for the element to mount, because the project notes say browser assertions do not wait for SPA paint. They do. visit() returns a PendingAwaitablePage backed by AwaitableWebpage, whose __call wraps every method in Execution::waitForExpectation and retries until the Playwright timeout, which defaults to five seconds. The plugin even deprecates waitForText in favour of assertSee for this reason. The loop was re-implementing the retry that already surrounded each call, less well and with a helper whose name has to be unique across the whole suite because these are global functions. Halves the file and drops the injected script. assertSeeLink also says more than the old check did: it asserts the labels are links, not just text that happens to appear. --------- Co-authored-by: Paulo Castellano <paulo@castellanos.llc>
This commit is contained in:
parent
b689e3902c
commit
0db9e0706d
24 changed files with 133 additions and 23 deletions
|
|
@ -51,6 +51,10 @@ public function share(Request $request): array
|
|||
'hasActiveSubscription' => $account ? $account->hasActiveSubscription() : false,
|
||||
'subscriptionPastDue' => $account ? $account->isPastDue() : false,
|
||||
],
|
||||
'legal' => [
|
||||
'terms' => (string) config('trypost.legal.terms_url'),
|
||||
'privacy' => (string) config('trypost.legal.privacy_url'),
|
||||
],
|
||||
'usage' => $account && ! $isSelfHosted ? $account->usage() : null,
|
||||
'features' => $account && ! $isSelfHosted ? $account->featureLimits() : null,
|
||||
'onboardingProgress' => $this->onboardingProgress($request, $user),
|
||||
|
|
|
|||
|
|
@ -16,6 +16,22 @@
|
|||
|
||||
'self_hosted' => env('SELF_HOSTED', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Legal pages
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Linked from the auth screens. Platform app reviews (TikTok explicitly)
|
||||
| require Terms and Privacy links to be clearly visible; self-hosted
|
||||
| installs point these at wherever they publish their own documents.
|
||||
|
|
||||
*/
|
||||
|
||||
'legal' => [
|
||||
'terms_url' => env('LEGAL_TERMS_URL', 'https://trypost.it/terms'),
|
||||
'privacy_url' => env('LEGAL_PRIVACY_URL', 'https://trypost.it/privacy'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Meta page walk budget
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'مرحبًا بك في TryPost! لقد بدأت فترتك التجريبية.',
|
||||
],
|
||||
|
||||
'legal' => 'بمتابعتك، فإنك توافق على <a href="https://trypost.it/terms" target="_blank">شروط الخدمة</a> و<a href="https://trypost.it/privacy" target="_blank">سياسة الخصوصية</a>.',
|
||||
'legal' => 'بمتابعتك، فإنك توافق على <a href=":terms_url" target="_blank">شروط الخدمة</a> و<a href=":privacy_url" target="_blank">سياسة الخصوصية</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
'welcome_trial' => 'Willkommen bei TryPost! Deine Testphase hat begonnen.',
|
||||
],
|
||||
|
||||
'legal' => 'Indem du fortfährst, stimmst du unseren <a href="https://trypost.it/terms" target="_blank">Nutzungsbedingungen</a> und unserer <a href="https://trypost.it/privacy" target="_blank">Datenschutzerklärung</a> zu.',
|
||||
'legal' => 'Indem du fortfährst, stimmst du unseren <a href=":terms_url" target="_blank">Nutzungsbedingungen</a> und unserer <a href=":privacy_url" target="_blank">Datenschutzerklärung</a> zu.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Καλώς ήρθατε στο TryPost! Η δοκιμαστική σας περίοδος ξεκίνησε.',
|
||||
],
|
||||
|
||||
'legal' => 'Συνεχίζοντας, συμφωνείτε με τους <a href="https://trypost.it/terms" target="_blank">Όρους Χρήσης</a> και την <a href="https://trypost.it/privacy" target="_blank">Πολιτική Απορρήτου</a> μας.',
|
||||
'legal' => 'Συνεχίζοντας, συμφωνείτε με τους <a href=":terms_url" target="_blank">Όρους Χρήσης</a> και την <a href=":privacy_url" target="_blank">Πολιτική Απορρήτου</a> μας.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Welcome to TryPost! Your trial has started.',
|
||||
],
|
||||
|
||||
'legal' => 'By continuing, you agree to our <a href="https://trypost.it/terms" target="_blank">Terms of Service</a> and <a href="https://trypost.it/privacy" target="_blank">Privacy Policy</a>.',
|
||||
'legal' => 'By continuing, you agree to our <a href=":terms_url" target="_blank">Terms of Service</a> and <a href=":privacy_url" target="_blank">Privacy Policy</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
'welcome_trial' => '¡Bienvenido a TryPost! Tu prueba ha comenzado.',
|
||||
],
|
||||
|
||||
'legal' => 'Al continuar, aceptas nuestros <a href="https://trypost.it/terms" target="_blank">Términos de Servicio</a> y <a href="https://trypost.it/privacy" target="_blank">Política de Privacidad</a>.',
|
||||
'legal' => 'Al continuar, aceptas nuestros <a href=":terms_url" target="_blank">Términos de Servicio</a> y <a href=":privacy_url" target="_blank">Política de Privacidad</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
@ -124,4 +124,5 @@
|
|||
'expired_description' => 'El workspace de esta invitación fue eliminado. Pide al propietario de la cuenta una nueva invitación si aún necesitas acceso.',
|
||||
'expired_action' => 'Ir al inicio',
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Bienvenue sur TryPost ! Votre essai a commencé.',
|
||||
],
|
||||
|
||||
'legal' => 'En continuant, vous acceptez nos <a href="https://trypost.it/terms" target="_blank">Conditions d\'utilisation</a> et notre <a href="https://trypost.it/privacy" target="_blank">Politique de confidentialité</a>.',
|
||||
'legal' => 'En continuant, vous acceptez nos <a href=":terms_url" target="_blank">Conditions d\'utilisation</a> et notre <a href=":privacy_url" target="_blank">Politique de confidentialité</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Benvenuto su TryPost! La tua prova è iniziata.',
|
||||
],
|
||||
|
||||
'legal' => 'Continuando, accetti i nostri <a href="https://trypost.it/terms" target="_blank">Termini di servizio</a> e la nostra <a href="https://trypost.it/privacy" target="_blank">Informativa sulla privacy</a>.',
|
||||
'legal' => 'Continuando, accetti i nostri <a href=":terms_url" target="_blank">Termini di servizio</a> e la nostra <a href=":privacy_url" target="_blank">Informativa sulla privacy</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'TryPost へようこそ!トライアルが開始されました。',
|
||||
],
|
||||
|
||||
'legal' => '続行すると、<a href="https://trypost.it/terms" target="_blank">利用規約</a>および<a href="https://trypost.it/privacy" target="_blank">プライバシーポリシー</a>に同意したものとみなされます。',
|
||||
'legal' => '続行すると、<a href=":terms_url" target="_blank">利用規約</a>および<a href=":privacy_url" target="_blank">プライバシーポリシー</a>に同意したものとみなされます。',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'TryPost에 오신 것을 환영합니다! 체험이 시작되었습니다.',
|
||||
],
|
||||
|
||||
'legal' => '계속 진행하면 <a href="https://trypost.it/terms" target="_blank">서비스 약관</a> 및 <a href="https://trypost.it/privacy" target="_blank">개인정보 처리방침</a>에 동의하는 것입니다.',
|
||||
'legal' => '계속 진행하면 <a href=":terms_url" target="_blank">서비스 약관</a> 및 <a href=":privacy_url" target="_blank">개인정보 처리방침</a>에 동의하는 것입니다.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Welkom bij TryPost! Je proefperiode is gestart.',
|
||||
],
|
||||
|
||||
'legal' => 'Door door te gaan ga je akkoord met onze <a href="https://trypost.it/terms" target="_blank">Servicevoorwaarden</a> en <a href="https://trypost.it/privacy" target="_blank">Privacybeleid</a>.',
|
||||
'legal' => 'Door door te gaan ga je akkoord met onze <a href=":terms_url" target="_blank">Servicevoorwaarden</a> en <a href=":privacy_url" target="_blank">Privacybeleid</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Witamy w TryPost! Twój okres próbny właśnie się rozpoczął.',
|
||||
],
|
||||
|
||||
'legal' => 'Kontynuując, akceptujesz nasze <a href="https://trypost.it/terms" target="_blank">Warunki korzystania z usługi</a> oraz <a href="https://trypost.it/privacy" target="_blank">Politykę prywatności</a>.',
|
||||
'legal' => 'Kontynuując, akceptujesz nasze <a href=":terms_url" target="_blank">Warunki korzystania z usługi</a> oraz <a href=":privacy_url" target="_blank">Politykę prywatności</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Bem-vindo ao TryPost! Seu período de teste começou.',
|
||||
],
|
||||
|
||||
'legal' => 'Ao continuar, você concorda com nossos <a href="https://trypost.it/terms" target="_blank">Termos de Serviço</a> e <a href="https://trypost.it/privacy" target="_blank">Política de Privacidade</a>.',
|
||||
'legal' => 'Ao continuar, você concorda com nossos <a href=":terms_url" target="_blank">Termos de Serviço</a> e <a href=":privacy_url" target="_blank">Política de Privacidade</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Добро пожаловать в TryPost! Ваш пробный период начался.',
|
||||
],
|
||||
|
||||
'legal' => 'Продолжая, вы соглашаетесь с нашими <a href="https://trypost.it/terms" target="_blank">Условиями использования</a> и <a href="https://trypost.it/privacy" target="_blank">Политикой конфиденциальности</a>.',
|
||||
'legal' => 'Продолжая, вы соглашаетесь с нашими <a href=":terms_url" target="_blank">Условиями использования</a> и <a href=":privacy_url" target="_blank">Политикой конфиденциальности</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
'welcome_trial' => 'TryPost\'a hoş geldiniz! Deneme süreniz başladı.',
|
||||
],
|
||||
|
||||
'legal' => 'Devam ederek <a href="https://trypost.it/terms" target="_blank">Hizmet Şartları</a> ve <a href="https://trypost.it/privacy" target="_blank">Gizlilik Politikası</a>\'nı kabul etmiş olursunuz.',
|
||||
'legal' => 'Devam ederek <a href=":terms_url" target="_blank">Hizmet Şartları</a> ve <a href=":privacy_url" target="_blank">Gizlilik Politikası</a>\'nı kabul etmiş olursunuz.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => 'Ласкаво просимо до TryPost! Ваш пробний період розпочато.',
|
||||
],
|
||||
|
||||
'legal' => 'Продовжуючи, ви погоджуєтеся з нашими <a href="https://trypost.it/terms" target="_blank">Умовами використання</a> та <a href="https://trypost.it/privacy" target="_blank">Політикою конфіденційності</a>.',
|
||||
'legal' => 'Продовжуючи, ви погоджуєтеся з нашими <a href=":terms_url" target="_blank">Умовами використання</a> та <a href=":privacy_url" target="_blank">Політикою конфіденційності</a>.',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
'welcome_trial' => '欢迎使用 TryPost!你的试用已开始。',
|
||||
],
|
||||
|
||||
'legal' => '继续即表示你同意我们的<a href="https://trypost.it/terms" target="_blank">服务条款</a>和<a href="https://trypost.it/privacy" target="_blank">隐私政策</a>。',
|
||||
'legal' => '继续即表示你同意我们的<a href=":terms_url" target="_blank">服务条款</a>和<a href=":privacy_url" target="_blank">隐私政策</a>。',
|
||||
|
||||
'slides' => [
|
||||
'calendar' => [
|
||||
|
|
|
|||
25
resources/js/components/auth/LegalLinks.vue
Normal file
25
resources/js/components/auth/LegalLinks.vue
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<script setup lang="ts">
|
||||
import { usePage } from '@inertiajs/vue3';
|
||||
import { trans } from 'laravel-vue-i18n';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import type { SharedData } from '@/types';
|
||||
|
||||
const page = usePage<SharedData>();
|
||||
|
||||
const sentence = computed(() =>
|
||||
trans('auth.legal', {
|
||||
terms_url: page.props.legal.terms,
|
||||
privacy_url: page.props.legal.privacy,
|
||||
}),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div
|
||||
data-testid="legal-links"
|
||||
class="text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary"
|
||||
v-html="sentence"
|
||||
/>
|
||||
</template>
|
||||
|
|
@ -3,6 +3,7 @@ import { Form, Head, usePage } from '@inertiajs/vue3';
|
|||
import { IconEye, IconEyeOff } from '@tabler/icons-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import LegalLinks from '@/components/auth/LegalLinks.vue';
|
||||
import SocialLogin from '@/components/auth/SocialLogin.vue';
|
||||
import InputError from '@/components/InputError.vue';
|
||||
import TextLink from '@/components/TextLink.vue';
|
||||
|
|
@ -183,6 +184,8 @@ const pageErrors = usePageErrors();
|
|||
}}</TextLink>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
<LegalLinks />
|
||||
</div>
|
||||
</AuthBase>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { Form, Head, usePage } from '@inertiajs/vue3';
|
|||
import { IconEye, IconEyeOff, IconMail } from '@tabler/icons-vue';
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import LegalLinks from '@/components/auth/LegalLinks.vue';
|
||||
import SocialLogin from '@/components/auth/SocialLogin.vue';
|
||||
import InputError from '@/components/InputError.vue';
|
||||
import TextLink from '@/components/TextLink.vue';
|
||||
|
|
@ -29,7 +30,6 @@ const showPassword = ref(false);
|
|||
const showEmailForm = ref(false);
|
||||
|
||||
const page = usePage();
|
||||
const isSelfHosted = computed(() => Boolean(page.props.selfHosted));
|
||||
const hasSocial = computed(
|
||||
() =>
|
||||
Boolean(page.props.googleAuthEnabled) ||
|
||||
|
|
@ -175,12 +175,7 @@ const emailFormVisible = computed(() => !hasSocial.value || showEmailForm.value)
|
|||
</div>
|
||||
</Form>
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div
|
||||
v-if="!isSelfHosted"
|
||||
class="text-center text-xs text-muted-foreground [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:text-primary"
|
||||
v-html="$t('auth.legal')"
|
||||
/>
|
||||
<LegalLinks />
|
||||
</div>
|
||||
</AuthBase>
|
||||
</template>
|
||||
|
|
|
|||
6
resources/js/types/index.d.ts
vendored
6
resources/js/types/index.d.ts
vendored
|
|
@ -85,6 +85,11 @@ export interface ContentTypeMediaRule {
|
|||
auto_fits_image: boolean;
|
||||
}
|
||||
|
||||
export interface LegalLinks {
|
||||
terms: string;
|
||||
privacy: string;
|
||||
}
|
||||
|
||||
export interface SharedData {
|
||||
name: string;
|
||||
auth: Auth;
|
||||
|
|
@ -93,6 +98,7 @@ export interface SharedData {
|
|||
sidebarOpen: boolean;
|
||||
selfHosted: boolean;
|
||||
allowMultipleSocialAccounts: boolean;
|
||||
legal: LegalLinks;
|
||||
contentTypeMediaRules?: Record<string, ContentTypeMediaRule>;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
|
|
|||
21
tests/Browser/AuthLegalLinksTest.php
Normal file
21
tests/Browser/AuthLegalLinksTest.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('the login screen shows the legal sentence to a logged out visitor', function () {
|
||||
visit(route('login'))
|
||||
->assertVisible('@legal-links')
|
||||
->assertSeeLink('Terms of Service')
|
||||
->assertSeeLink('Privacy Policy')
|
||||
->assertNoJavaScriptErrors();
|
||||
});
|
||||
|
||||
test('the register screen shows the legal sentence to a logged out visitor', function () {
|
||||
config(['trypost.self_hosted' => false]);
|
||||
|
||||
visit(route('register'))
|
||||
->assertVisible('@legal-links')
|
||||
->assertSeeLink('Terms of Service')
|
||||
->assertSeeLink('Privacy Policy')
|
||||
->assertNoJavaScriptErrors();
|
||||
});
|
||||
39
tests/Feature/Auth/LegalLinksTest.php
Normal file
39
tests/Feature/Auth/LegalLinksTest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
test('auth screens receive the configured legal links', function (string $route) {
|
||||
config()->set('trypost.self_hosted', false);
|
||||
config()->set('trypost.legal.terms_url', 'https://example.test/terms');
|
||||
config()->set('trypost.legal.privacy_url', 'https://example.test/privacy');
|
||||
|
||||
$this->get(route($route))
|
||||
->assertOk()
|
||||
->assertInertia(fn ($page) => $page
|
||||
->where('legal.terms', 'https://example.test/terms')
|
||||
->where('legal.privacy', 'https://example.test/privacy')
|
||||
);
|
||||
})->with(['login', 'register']);
|
||||
|
||||
test('a self-hosted install can point the legal links at its own documents', function () {
|
||||
config()->set('trypost.legal.terms_url', 'https://acme.test/legal/tos');
|
||||
config()->set('trypost.legal.privacy_url', 'https://acme.test/legal/privacy');
|
||||
|
||||
$this->get(route('login'))
|
||||
->assertInertia(fn ($page) => $page
|
||||
->where('legal.terms', 'https://acme.test/legal/tos')
|
||||
->where('legal.privacy', 'https://acme.test/legal/privacy')
|
||||
);
|
||||
});
|
||||
|
||||
test('the legal sentence carries a url placeholder rather than a hardcoded host', function (string $locale) {
|
||||
$sentence = require base_path("lang/{$locale}/auth.php");
|
||||
|
||||
expect($sentence['legal'])
|
||||
->toContain(':terms_url')
|
||||
->toContain(':privacy_url')
|
||||
->not->toContain('trypost.it');
|
||||
})->with(array_map(
|
||||
fn (string $path) => basename(dirname($path)),
|
||||
glob(dirname(__DIR__, 3).'/lang/*/auth.php'),
|
||||
));
|
||||
Loading…
Reference in a new issue