From 71eb0ec74f9e88a1c7d82e8412a8b959455c959e Mon Sep 17 00:00:00 2001 From: LucHeart Date: Thu, 3 Dec 2026 02:38:46 +0100 Subject: [PATCH 1/3] feat: password protected public shares - owners can set a password when creating a public share and set, change or remove it on the edit page - visitors enter it before the guest or login choice; the unlock is kept for the tab and sent to the hub - if the password changes while connected, the visitor is sent back to the password prompt - lock icon on password protected shares in the list - add the problem types missing from the registry (password errors and three older ones) --- e2e/integration/public-share-password.spec.ts | 70 ++++++++++ messages/de.json | 9 ++ messages/en.json | 26 ++++ messages/es.json | 9 ++ messages/et.json | 9 ++ messages/fi.json | 9 ++ messages/fr.json | 9 ++ messages/ja.json | 9 ++ messages/nb.json | 9 ++ messages/nl.json | 9 ++ messages/sv.json | 9 ++ messages/uk.json | 9 ++ messages/uwu.json | 9 ++ messages/zh-Hans.json | 9 ++ messages/zh-Hant.json | 9 ++ src/lib/api/internal/generated/index.ts | 15 ++ src/lib/api/internal/generated/sdk.gen.ts | 68 ++++++++- .../internal/generated/transformers.gen.ts | 21 +++ src/lib/api/internal/generated/types.gen.ts | 119 ++++++++++++++++ .../public-share/ControlView.svelte | 8 +- .../public-share/PublicShareView.svelte | 130 ++++++++++++++++-- src/lib/errorhandling/problemMessages.ts | 17 +++ src/lib/errorhandling/problemTypes.ts | 18 +++ src/lib/signalr/sharelink.svelte.ts | 39 +++++- src/lib/utils/public-share-unlock.test.ts | 37 +++++ src/lib/utils/public-share-unlock.ts | 42 ++++++ src/routes/(app)/shares/public/+page.svelte | 14 +- .../public/[shareId=guid]/edit/+page.svelte | 2 + .../edit/share-password-card.svelte | 96 +++++++++++++ .../public/dialog-publicshare-create.svelte | 37 ++++- .../shares/public/[shareId=guid]/+page.svelte | 4 +- src/routes/u/[username]/+page.svelte | 4 +- 32 files changed, 856 insertions(+), 28 deletions(-) create mode 100644 e2e/integration/public-share-password.spec.ts create mode 100644 src/lib/utils/public-share-unlock.test.ts create mode 100644 src/lib/utils/public-share-unlock.ts create mode 100644 src/routes/(app)/shares/public/[shareId=guid]/edit/share-password-card.svelte diff --git a/e2e/integration/public-share-password.spec.ts b/e2e/integration/public-share-password.spec.ts new file mode 100644 index 00000000..2c70d32d --- /dev/null +++ b/e2e/integration/public-share-password.spec.ts @@ -0,0 +1,70 @@ +import { expect, test } from './lib/test-fixtures'; + +test.describe('public share passwords', () => { + test('visitors unlock a password protected public share', async ({ + authedPage, + browser, + user, + }) => { + const username = user.credentials.username; + const page = authedPage; + + // Create a password protected public share + await page.goto('/shares/public'); + await page.getByRole('main').getByRole('button', { name: 'New Share' }).first().click(); + const dialog = page.getByRole('dialog'); + await dialog.getByLabel('Name').fill('Locked Share'); + await dialog.getByLabel('Custom URL').fill('locked'); + await dialog.getByLabel('Password (optional)').fill('abc'); + await expect(dialog.getByText('Use 4 to 128 characters.')).toBeVisible(); + await expect(dialog.getByRole('button', { name: 'Create' })).toBeDisabled(); + await dialog.getByLabel('Password (optional)').fill('open sesame'); + await dialog.getByRole('button', { name: 'Create' }).click(); + await expect(page.getByText('Created new public share')).toBeVisible(); + await expect(page.getByLabel('Password protected')).toBeVisible(); + + // A visitor has to enter the password first + const anon = await browser.newContext(); + const visitor = await anon.newPage(); + await visitor.goto(`/u/${username}/locked`); + await expect(visitor.getByRole('heading', { name: 'Locked Share' })).toBeVisible(); + await expect(visitor.getByText('This public share is password protected.')).toBeVisible(); + await expect(visitor.getByRole('button', { name: 'Enter as Guest' })).toBeHidden(); + + await visitor.getByLabel('Password').fill('wrong password'); + await visitor.getByRole('button', { name: 'Unlock' }).click(); + await expect(visitor.getByText('Incorrect password')).toBeVisible(); + + await visitor.getByLabel('Password').fill('open sesame'); + await visitor.getByRole('button', { name: 'Unlock' }).click(); + await expect(visitor.getByRole('button', { name: 'Enter as Guest' })).toBeVisible(); + + // The unlock is remembered for the tab + await visitor.reload(); + await expect(visitor.getByRole('button', { name: 'Enter as Guest' })).toBeVisible(); + + // Changing the password locks the visitor out again + await page.getByRole('heading', { name: 'Locked Share' }).click(); + await expect(page).toHaveURL(/\/shares\/public\/[0-9a-f-]+$/); + await page.goto(`${page.url()}/edit`); + const passwordCard = page.locator('[data-slot="card"]', { + hasText: 'Visitors have to enter it', + }); + await passwordCard.getByLabel('New password').fill('new secret'); + await passwordCard.getByRole('button', { name: 'Change password' }).click(); + await expect(page.getByText('Password saved')).toBeVisible(); + + await visitor.reload(); + await expect(visitor.getByText('This public share is password protected.')).toBeVisible(); + + // Removing it opens the share + await passwordCard.getByRole('button', { name: 'Remove password' }).click(); + await expect(page.getByText('Password removed')).toBeVisible(); + await expect(passwordCard.getByText(/No password/)).toBeVisible(); + + await visitor.reload(); + await expect(visitor.getByRole('button', { name: 'Enter as Guest' })).toBeVisible(); + + await anon.close(); + }); +}); diff --git a/messages/de.json b/messages/de.json index f1efb63e..ff9209d9 100644 --- a/messages/de.json +++ b/messages/de.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Ungültige benutzerdefinierte URL", "problem_share_link_slug_invalid_desc": "Verwende 2–32 Kleinbuchstaben, Ziffern und einzelne Bindestriche, ohne Bindestrich am Anfang oder Ende.", "problem_share_link_slug_taken_title": "Du hast bereits eine öffentliche Freigabe mit dieser benutzerdefinierten URL", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Mindestens ein Eintrag ist keine gültige Domain, es wurde nichts hinzugefügt", + "problem_share_shocker_share_limit_reached_title": "Shocker hat zu viele Freigaben", + "problem_share_shocker_share_limit_reached_desc": "Ein Shocker kann mit höchstens 100 Nutzern geteilt werden.", + "problem_share_link_too_many_share_links_title": "Du hast zu viele öffentliche Freigaben", + "problem_share_link_too_many_share_links_desc": "Du hast das Maximum von 500 öffentlichen Freigaben erreicht.", + "problem_share_link_not_password_protected_title": "Diese öffentliche Freigabe hat kein Passwort", + "problem_share_link_password_incorrect_title": "Falsches Passwort", + "problem_share_link_too_many_password_attempts_title": "Zu viele falsche Passwörter", + "problem_share_link_too_many_password_attempts_desc": "Für diese öffentliche Freigabe wurden zu viele falsche Passwörter eingegeben. Versuche es in ein paar Minuten erneut.", "problem_user_profile_not_found_title": "Profil nicht gefunden", "problem_user_profile_default_public_share_not_found_title": "Standardmäßige öffentliche Freigabe nicht gefunden", "problem_user_profile_default_public_share_not_found_desc": "Sie ist möglicherweise abgelaufen oder wurde gelöscht.", diff --git a/messages/en.json b/messages/en.json index fc97c654..94b3021f 100644 --- a/messages/en.json +++ b/messages/en.json @@ -886,6 +886,23 @@ "public_share_custom_url_optional": "Optional, lowercase letters, numbers and hyphens", "public_share_slug_invalid": "Use 2-32 lowercase letters, numbers and single hyphens", "public_share_slug_not_found_desc": "This public share does not exist, or its custom URL has changed.", + "public_share_password_title": "Password", + "public_share_password_settings_desc": "Visitors have to enter it before they can see or control the shockers. Setting or changing it disconnects everyone using this public share.", + "public_share_password_status_on": "Password protected", + "public_share_password_status_off": "No password, anyone with the link can use it", + "public_share_password_label": "Password", + "public_share_password_new": "New password", + "public_share_password_optional": "Password (optional)", + "public_share_password_set": "Set password", + "public_share_password_change": "Change password", + "public_share_password_remove": "Remove password", + "public_share_password_length": "Use {{min}} to {{max}} characters.", + "public_share_password_toast_set": "Password saved", + "public_share_password_toast_removed": "Password removed", + "public_share_password_desc": "This public share is password protected.", + "public_share_password_placeholder": "Enter the password", + "public_share_password_unlock": "Unlock", + "public_share_password_changed": "The password was changed. Enter the new one to continue.", "public_share_settings_title": "Settings", "public_share_settings_desc": "Name, custom URL and expiry of this public share.", "public_share_toast_settings_saved": "Public share updated", @@ -1140,6 +1157,15 @@ "problem_share_link_slug_invalid_title": "Invalid custom URL", "problem_share_link_slug_invalid_desc": "Use 2-32 lowercase letters, numbers and single hyphens, not starting or ending with a hyphen.", "problem_share_link_slug_taken_title": "You already have a public share with this custom URL", + "problem_admin_email_provider_blacklist_invalid_domains_title": "One or more entries are not valid domains, nothing was added", + "problem_share_shocker_share_limit_reached_title": "Shocker has too many shares", + "problem_share_shocker_share_limit_reached_desc": "A shocker can be shared with at most 100 users.", + "problem_share_link_too_many_share_links_title": "You have too many public shares", + "problem_share_link_too_many_share_links_desc": "You have reached the maximum of 500 public shares.", + "problem_share_link_not_password_protected_title": "This public share has no password", + "problem_share_link_password_incorrect_title": "Incorrect password", + "problem_share_link_too_many_password_attempts_title": "Too many incorrect passwords", + "problem_share_link_too_many_password_attempts_desc": "Too many incorrect passwords were entered for this public share. Try again in a few minutes.", "problem_user_profile_not_found_title": "Profile not found", "problem_user_profile_default_public_share_not_found_title": "Default public share not found", "problem_user_profile_default_public_share_not_found_desc": "It may have expired or been deleted.", diff --git a/messages/es.json b/messages/es.json index 5963ef2f..f7444f0c 100644 --- a/messages/es.json +++ b/messages/es.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "URL personalizada no válida", "problem_share_link_slug_invalid_desc": "Usa de 2 a 32 letras minúsculas, números y guiones simples, sin empezar ni terminar con un guion.", "problem_share_link_slug_taken_title": "Ya tienes un enlace público con esta URL personalizada", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Una o más entradas no son dominios válidos, no se añadió nada", + "problem_share_shocker_share_limit_reached_title": "El shocker tiene demasiados accesos compartidos", + "problem_share_shocker_share_limit_reached_desc": "Un shocker se puede compartir con un máximo de 100 usuarios.", + "problem_share_link_too_many_share_links_title": "Tienes demasiados enlaces públicos", + "problem_share_link_too_many_share_links_desc": "Has alcanzado el máximo de 500 enlaces públicos.", + "problem_share_link_not_password_protected_title": "Este enlace público no tiene contraseña", + "problem_share_link_password_incorrect_title": "Contraseña incorrecta", + "problem_share_link_too_many_password_attempts_title": "Demasiadas contraseñas incorrectas", + "problem_share_link_too_many_password_attempts_desc": "Se introdujeron demasiadas contraseñas incorrectas para este enlace público. Inténtalo de nuevo en unos minutos.", "problem_user_profile_not_found_title": "No se encontró el perfil", "problem_user_profile_default_public_share_not_found_title": "No se encontró el enlace público predeterminado", "problem_user_profile_default_public_share_not_found_desc": "Puede que haya caducado o se haya eliminado.", diff --git a/messages/et.json b/messages/et.json index 4fff8de0..5ef03f5d 100644 --- a/messages/et.json +++ b/messages/et.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Vigane kohandatud URL", "problem_share_link_slug_invalid_desc": "Kasuta 2–32 väiketähte, numbrit ja üksikut sidekriipsu, mis ei alga ega lõppe sidekriipsuga.", "problem_share_link_slug_taken_title": "Sul on juba selle kohandatud URL-iga avalik jagamine", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Üks või mitu kirjet ei ole kehtivad domeenid, midagi ei lisatud", + "problem_share_shocker_share_limit_reached_title": "Šokeril on liiga palju jagamisi", + "problem_share_shocker_share_limit_reached_desc": "Šokerit saab jagada kõige rohkem 100 kasutajaga.", + "problem_share_link_too_many_share_links_title": "Sul on liiga palju avalikke jagamisi", + "problem_share_link_too_many_share_links_desc": "Oled jõudnud 500 avaliku jagamise piirini.", + "problem_share_link_not_password_protected_title": "Sellel avalikul jagamisel pole parooli", + "problem_share_link_password_incorrect_title": "Vale parool", + "problem_share_link_too_many_password_attempts_title": "Liiga palju valesid paroole", + "problem_share_link_too_many_password_attempts_desc": "Selle avaliku jagamise jaoks sisestati liiga palju valesid paroole. Proovi mõne minuti pärast uuesti.", "problem_user_profile_not_found_title": "Profiili ei leitud", "problem_user_profile_default_public_share_not_found_title": "Vaikimisi avalikku jagamist ei leitud", "problem_user_profile_default_public_share_not_found_desc": "See võib olla aegunud või kustutatud.", diff --git a/messages/fi.json b/messages/fi.json index a2bf0621..660eecda 100644 --- a/messages/fi.json +++ b/messages/fi.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Virheellinen mukautettu URL", "problem_share_link_slug_invalid_desc": "Käytä 2–32 pientä kirjainta, numeroa ja yksittäistä yhdysmerkkiä, ei yhdysmerkkiä alussa tai lopussa.", "problem_share_link_slug_taken_title": "Sinulla on jo julkinen jako tällä mukautetulla URL-osoitteella", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Yksi tai useampi merkintä ei ole kelvollinen verkkotunnus, mitään ei lisätty", + "problem_share_shocker_share_limit_reached_title": "Shockerilla on liian monta jakoa", + "problem_share_shocker_share_limit_reached_desc": "Shockerin voi jakaa enintään 100 käyttäjälle.", + "problem_share_link_too_many_share_links_title": "Sinulla on liian monta julkista jakoa", + "problem_share_link_too_many_share_links_desc": "Olet saavuttanut 500 julkisen jaon enimmäismäärän.", + "problem_share_link_not_password_protected_title": "Tällä julkisella jaolla ei ole salasanaa", + "problem_share_link_password_incorrect_title": "Väärä salasana", + "problem_share_link_too_many_password_attempts_title": "Liian monta väärää salasanaa", + "problem_share_link_too_many_password_attempts_desc": "Tälle julkiselle jaolle syötettiin liian monta väärää salasanaa. Yritä uudelleen muutaman minuutin kuluttua.", "problem_user_profile_not_found_title": "Profiilia ei löytynyt", "problem_user_profile_default_public_share_not_found_title": "Oletusarvoista julkista jakoa ei löytynyt", "problem_user_profile_default_public_share_not_found_desc": "Se on voinut vanhentua tai se on poistettu.", diff --git a/messages/fr.json b/messages/fr.json index 0d867da8..19659627 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "URL personnalisée invalide", "problem_share_link_slug_invalid_desc": "Utilise de 2 à 32 lettres minuscules, chiffres et tirets simples, sans tiret au début ni à la fin.", "problem_share_link_slug_taken_title": "Tu as déjà un partage public avec cette URL personnalisée", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Une ou plusieurs entrées ne sont pas des domaines valides, rien n’a été ajouté", + "problem_share_shocker_share_limit_reached_title": "Le shocker a trop de partages", + "problem_share_shocker_share_limit_reached_desc": "Un shocker peut être partagé avec 100 utilisateurs au maximum.", + "problem_share_link_too_many_share_links_title": "Tu as trop de partages publics", + "problem_share_link_too_many_share_links_desc": "Tu as atteint le maximum de 500 partages publics.", + "problem_share_link_not_password_protected_title": "Ce partage public n’a pas de mot de passe", + "problem_share_link_password_incorrect_title": "Mot de passe incorrect", + "problem_share_link_too_many_password_attempts_title": "Trop de mots de passe incorrects", + "problem_share_link_too_many_password_attempts_desc": "Trop de mots de passe incorrects ont été saisis pour ce partage public. Réessaie dans quelques minutes.", "problem_user_profile_not_found_title": "Profil introuvable", "problem_user_profile_default_public_share_not_found_title": "Partage public par défaut introuvable", "problem_user_profile_default_public_share_not_found_desc": "Il a peut-être expiré ou été supprimé.", diff --git a/messages/ja.json b/messages/ja.json index 4a45637a..78c3ac30 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -1050,6 +1050,15 @@ "problem_share_link_slug_invalid_title": "カスタムURLが無効です", "problem_share_link_slug_invalid_desc": "小文字、数字、単一のハイフンを2~32文字で使用してください。先頭と末尾にハイフンは使えません。", "problem_share_link_slug_taken_title": "このカスタムURLの公開共有はすでにあります", + "problem_admin_email_provider_blacklist_invalid_domains_title": "無効なドメインが含まれているため、何も追加されませんでした", + "problem_share_shocker_share_limit_reached_title": "このショッカーの共有が多すぎます", + "problem_share_shocker_share_limit_reached_desc": "ショッカーは最大100人のユーザーと共有できます。", + "problem_share_link_too_many_share_links_title": "公開共有が多すぎます", + "problem_share_link_too_many_share_links_desc": "公開共有の上限(500件)に達しました。", + "problem_share_link_not_password_protected_title": "この公開共有にはパスワードがありません", + "problem_share_link_password_incorrect_title": "パスワードが正しくありません", + "problem_share_link_too_many_password_attempts_title": "パスワードの入力ミスが多すぎます", + "problem_share_link_too_many_password_attempts_desc": "この公開共有に対して誤ったパスワードが何度も入力されました。数分後にもう一度お試しください。", "problem_user_profile_not_found_title": "プロフィールが見つかりません", "problem_user_profile_default_public_share_not_found_title": "デフォルトの公開共有が見つかりません", "problem_user_profile_default_public_share_not_found_desc": "期限切れか、削除された可能性があります。", diff --git a/messages/nb.json b/messages/nb.json index db6c9ab9..61d911f3 100644 --- a/messages/nb.json +++ b/messages/nb.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Ugyldig egendefinert URL", "problem_share_link_slug_invalid_desc": "Bruk 2–32 små bokstaver, tall og enkle bindestreker, uten bindestrek først eller sist.", "problem_share_link_slug_taken_title": "Du har allerede en delingslenke med denne egendefinerte URL-en", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Én eller flere oppføringer er ikke gyldige domener, ingenting ble lagt til", + "problem_share_shocker_share_limit_reached_title": "Shockeren har for mange delinger", + "problem_share_shocker_share_limit_reached_desc": "En shocker kan deles med høyst 100 brukere.", + "problem_share_link_too_many_share_links_title": "Du har for mange delingslenker", + "problem_share_link_too_many_share_links_desc": "Du har nådd maksimum på 500 delingslenker.", + "problem_share_link_not_password_protected_title": "Denne delingslenken har ikke passord", + "problem_share_link_password_incorrect_title": "Feil passord", + "problem_share_link_too_many_password_attempts_title": "For mange feil passord", + "problem_share_link_too_many_password_attempts_desc": "Det ble skrevet inn for mange feil passord for denne delingslenken. Prøv igjen om noen minutter.", "problem_user_profile_not_found_title": "Fant ikke profilen", "problem_user_profile_default_public_share_not_found_title": "Fant ikke standard delingslenke", "problem_user_profile_default_public_share_not_found_desc": "Den kan ha utløpt eller blitt slettet.", diff --git a/messages/nl.json b/messages/nl.json index 491c72e2..8bdad6fa 100644 --- a/messages/nl.json +++ b/messages/nl.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Ongeldige aangepaste URL", "problem_share_link_slug_invalid_desc": "Gebruik 2–32 kleine letters, cijfers en enkele koppeltekens, zonder koppelteken aan het begin of eind.", "problem_share_link_slug_taken_title": "Je hebt al een openbare deling met deze aangepaste URL", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Een of meer items zijn geen geldige domeinen, er is niets toegevoegd", + "problem_share_shocker_share_limit_reached_title": "Shocker heeft te veel deelacties", + "problem_share_shocker_share_limit_reached_desc": "Een shocker kan met maximaal 100 gebruikers worden gedeeld.", + "problem_share_link_too_many_share_links_title": "Je hebt te veel openbare delingen", + "problem_share_link_too_many_share_links_desc": "Je hebt het maximum van 500 openbare delingen bereikt.", + "problem_share_link_not_password_protected_title": "Deze openbare deling heeft geen wachtwoord", + "problem_share_link_password_incorrect_title": "Onjuist wachtwoord", + "problem_share_link_too_many_password_attempts_title": "Te veel onjuiste wachtwoorden", + "problem_share_link_too_many_password_attempts_desc": "Er zijn te veel onjuiste wachtwoorden ingevoerd voor deze openbare deling. Probeer het over een paar minuten opnieuw.", "problem_user_profile_not_found_title": "Profiel niet gevonden", "problem_user_profile_default_public_share_not_found_title": "Standaard openbare deling niet gevonden", "problem_user_profile_default_public_share_not_found_desc": "Deze is mogelijk verlopen of verwijderd.", diff --git a/messages/sv.json b/messages/sv.json index aebe6009..d30bd1d2 100644 --- a/messages/sv.json +++ b/messages/sv.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "Ogiltig anpassad URL", "problem_share_link_slug_invalid_desc": "Använd 2–32 små bokstäver, siffror och enstaka bindestreck, utan bindestreck först eller sist.", "problem_share_link_slug_taken_title": "Du har redan en offentlig delning med den här anpassade URL:en", + "problem_admin_email_provider_blacklist_invalid_domains_title": "En eller flera poster är inte giltiga domäner, inget lades till", + "problem_share_shocker_share_limit_reached_title": "Shockern har för många delningar", + "problem_share_shocker_share_limit_reached_desc": "En shocker kan delas med högst 100 användare.", + "problem_share_link_too_many_share_links_title": "Du har för många offentliga delningar", + "problem_share_link_too_many_share_links_desc": "Du har nått maxgränsen på 500 offentliga delningar.", + "problem_share_link_not_password_protected_title": "Den här offentliga delningen har inget lösenord", + "problem_share_link_password_incorrect_title": "Fel lösenord", + "problem_share_link_too_many_password_attempts_title": "För många felaktiga lösenord", + "problem_share_link_too_many_password_attempts_desc": "För många felaktiga lösenord har angetts för den här offentliga delningen. Försök igen om några minuter.", "problem_user_profile_not_found_title": "Profilen hittades inte", "problem_user_profile_default_public_share_not_found_title": "Den förvalda offentliga delningen hittades inte", "problem_user_profile_default_public_share_not_found_desc": "Den kan ha gått ut eller tagits bort.", diff --git a/messages/uk.json b/messages/uk.json index e4f3ef45..05120621 100644 --- a/messages/uk.json +++ b/messages/uk.json @@ -1065,6 +1065,15 @@ "problem_share_link_slug_invalid_title": "Недійсна власна URL-адреса", "problem_share_link_slug_invalid_desc": "Використовуйте 2–32 малі літери, цифри та поодинокі дефіси, без дефіса на початку чи в кінці.", "problem_share_link_slug_taken_title": "У вас уже є публічне посилання з цією власною URL-адресою", + "problem_admin_email_provider_blacklist_invalid_domains_title": "Один або кілька записів не є дійсними доменами, нічого не додано", + "problem_share_shocker_share_limit_reached_title": "Шокер має забагато спільних доступів", + "problem_share_shocker_share_limit_reached_desc": "Шокер можна поділити щонайбільше зі 100 користувачами.", + "problem_share_link_too_many_share_links_title": "У вас забагато публічних посилань", + "problem_share_link_too_many_share_links_desc": "Ви досягли максимуму в 500 публічних посилань.", + "problem_share_link_not_password_protected_title": "Це публічне посилання не має пароля", + "problem_share_link_password_incorrect_title": "Неправильний пароль", + "problem_share_link_too_many_password_attempts_title": "Забагато неправильних паролів", + "problem_share_link_too_many_password_attempts_desc": "Для цього публічного посилання введено забагато неправильних паролів. Спробуйте ще раз за кілька хвилин.", "problem_user_profile_not_found_title": "Профіль не знайдено", "problem_user_profile_default_public_share_not_found_title": "Публічне посилання за замовчуванням не знайдено", "problem_user_profile_default_public_share_not_found_desc": "Можливо, термін його дії минув або його видалено.", diff --git a/messages/uwu.json b/messages/uwu.json index a280e19c..cf33402d 100644 --- a/messages/uwu.json +++ b/messages/uwu.json @@ -1055,6 +1055,15 @@ "problem_share_link_slug_invalid_title": "That custom URL is all wonky", "problem_share_link_slug_invalid_desc": "Use 2-32 wowercase wetters, numbers and singwe hyphens, no hyphen at the stawt ow end, pwease~", "problem_share_link_slug_taken_title": "You alweady have a public share with that custom URL", + "problem_admin_email_provider_blacklist_invalid_domains_title": "One ow mowe entwies awen't vawid domains, nyothing was added >w<", + "problem_share_shocker_share_limit_reached_title": "Shockew has too many shawes", + "problem_share_shocker_share_limit_reached_desc": "A shockew can be shawed with at most 100 usews.", + "problem_share_link_too_many_share_links_title": "You have too many pubwic shawes", + "problem_share_link_too_many_share_links_desc": "You've weached the maximum of 500 pubwic shawes.", + "problem_share_link_not_password_protected_title": "This pubwic shawe has nyo passwowd", + "problem_share_link_password_incorrect_title": "Incowwect passwowd", + "problem_share_link_too_many_password_attempts_title": "Too many wwong passwowds", + "problem_share_link_too_many_password_attempts_desc": "Too many wwong passwowds wewe entewed fow this pubwic shawe. Twy again in a few minutes uwu", "problem_user_profile_not_found_title": "Couldn't sniff out that profile", "problem_user_profile_default_public_share_not_found_title": "Couldn't sniff out your defauwt public share", "problem_user_profile_default_public_share_not_found_desc": "It might have expiwed ow been deweted.", diff --git a/messages/zh-Hans.json b/messages/zh-Hans.json index 2454b747..47d660b6 100644 --- a/messages/zh-Hans.json +++ b/messages/zh-Hans.json @@ -1050,6 +1050,15 @@ "problem_share_link_slug_invalid_title": "自定义 URL 无效", "problem_share_link_slug_invalid_desc": "请使用 2–32 个小写字母、数字和单个连字符,且不能以连字符开头或结尾。", "problem_share_link_slug_taken_title": "你已有使用此自定义 URL 的公开共享", + "problem_admin_email_provider_blacklist_invalid_domains_title": "一个或多个条目不是有效域名,未添加任何内容", + "problem_share_shocker_share_limit_reached_title": "该电击器的共享过多", + "problem_share_shocker_share_limit_reached_desc": "一个电击器最多可与 100 位用户共享。", + "problem_share_link_too_many_share_links_title": "你的公开共享过多", + "problem_share_link_too_many_share_links_desc": "你已达到 500 个公开共享的上限。", + "problem_share_link_not_password_protected_title": "此公开共享没有密码", + "problem_share_link_password_incorrect_title": "密码错误", + "problem_share_link_too_many_password_attempts_title": "密码错误次数过多", + "problem_share_link_too_many_password_attempts_desc": "此公开共享的密码错误次数过多。请几分钟后再试。", "problem_user_profile_not_found_title": "未找到个人资料", "problem_user_profile_default_public_share_not_found_title": "未找到默认公开共享", "problem_user_profile_default_public_share_not_found_desc": "它可能已过期或已被删除。", diff --git a/messages/zh-Hant.json b/messages/zh-Hant.json index 7423708b..85c18ba3 100644 --- a/messages/zh-Hant.json +++ b/messages/zh-Hant.json @@ -1050,6 +1050,15 @@ "problem_share_link_slug_invalid_title": "自訂網址無效", "problem_share_link_slug_invalid_desc": "請使用 2–32 個小寫字母、數字和單一連字號,且不能以連字號開頭或結尾。", "problem_share_link_slug_taken_title": "你已有使用此自訂網址的公開分享", + "problem_admin_email_provider_blacklist_invalid_domains_title": "一個或多個項目不是有效網域,未新增任何內容", + "problem_share_shocker_share_limit_reached_title": "該電擊器的共享過多", + "problem_share_shocker_share_limit_reached_desc": "一個電擊器最多可與 100 位使用者共享。", + "problem_share_link_too_many_share_links_title": "你的公開分享過多", + "problem_share_link_too_many_share_links_desc": "你已達到 500 個公開分享的上限。", + "problem_share_link_not_password_protected_title": "此公開分享沒有密碼", + "problem_share_link_password_incorrect_title": "密碼錯誤", + "problem_share_link_too_many_password_attempts_title": "密碼錯誤次數過多", + "problem_share_link_too_many_password_attempts_desc": "此公開分享的密碼錯誤次數過多。請幾分鐘後再試。", "problem_user_profile_not_found_title": "找不到個人檔案", "problem_user_profile_default_public_share_not_found_title": "找不到預設公開分享", "problem_user_profile_default_public_share_not_found_desc": "它可能已過期或已被刪除。", diff --git a/src/lib/api/internal/generated/index.ts b/src/lib/api/internal/generated/index.ts index 31703460..958c5b3d 100644 --- a/src/lib/api/internal/generated/index.ts +++ b/src/lib/api/internal/generated/index.ts @@ -80,6 +80,7 @@ export { publicGetPublicShare, publicGetPublicShareBySlug, publicGetUserProfile, + publicUnlockPublicShare, sessionsDeleteSession, sessionsGetSelfSession, sessionsListSessions, @@ -91,6 +92,7 @@ export { shareLinksList, shareLinksPauseShocker, shareLinksRemoveShocker, + shareLinksSetPublicSharePassword, sharesDeleteShareCode, sharesLinkShareCode, shockerEditShocker, @@ -595,8 +597,16 @@ export { type PublicShareDevice, type PublicShareEdit, type PublicShareEditShocker, + type PublicSharePasswordSet, type PublicShareResponse, type PublicShareShocker, + type PublicShareUnlock, + type PublicShareUnlockResponse, + type PublicUnlockPublicShareData, + type PublicUnlockPublicShareError, + type PublicUnlockPublicShareErrors, + type PublicUnlockPublicShareResponse, + type PublicUnlockPublicShareResponses, type PublicUserProfileDetails, type PublicUserProfilePublicShare, type PublicUserProfileResponse, @@ -659,6 +669,11 @@ export { type ShareLinksRemoveShockerErrors, type ShareLinksRemoveShockerResponse, type ShareLinksRemoveShockerResponses, + type ShareLinksSetPublicSharePasswordData, + type ShareLinksSetPublicSharePasswordError, + type ShareLinksSetPublicSharePasswordErrors, + type ShareLinksSetPublicSharePasswordResponse, + type ShareLinksSetPublicSharePasswordResponses, type SharedDevice, type SharedShocker, type SharesDeleteShareCodeData, diff --git a/src/lib/api/internal/generated/sdk.gen.ts b/src/lib/api/internal/generated/sdk.gen.ts index 8aa114c4..209ed050 100644 --- a/src/lib/api/internal/generated/sdk.gen.ts +++ b/src/lib/api/internal/generated/sdk.gen.ts @@ -28,10 +28,12 @@ import { publicGetOnlineDevicesStatisticsResponseTransformer, publicGetPublicShareBySlugResponseTransformer, publicGetPublicShareResponseTransformer, + publicUnlockPublicShareResponseTransformer, sessionsGetSelfSessionResponseTransformer, sessionsListSessionsResponseTransformer, shareLinksEditPublicShareResponseTransformer, shareLinksListResponseTransformer, + shareLinksSetPublicSharePasswordResponseTransformer, shockerGetAllShockerLogsResponseTransformer, shockerGetShockerByIdResponseTransformer, shockerGetShockerLogsResponseTransformer, @@ -271,6 +273,9 @@ import type { PublicGetUserProfileData, PublicGetUserProfileErrors, PublicGetUserProfileResponses, + PublicUnlockPublicShareData, + PublicUnlockPublicShareErrors, + PublicUnlockPublicShareResponses, SessionsDeleteSessionData, SessionsDeleteSessionErrors, SessionsDeleteSessionResponses, @@ -301,6 +306,9 @@ import type { ShareLinksRemoveShockerData, ShareLinksRemoveShockerErrors, ShareLinksRemoveShockerResponses, + ShareLinksSetPublicSharePasswordData, + ShareLinksSetPublicSharePasswordErrors, + ShareLinksSetPublicSharePasswordResponses, SharesDeleteShareCodeData, SharesDeleteShareCodeErrors, SharesDeleteShareCodeResponses, @@ -836,7 +844,8 @@ export const shockerSendControl = ( /** * Set the global permissions and limits of a shocker. They apply to every control of the shocker, including - * the owner's own, on top of any share or token restrictions. A null limit means uncapped. + * the owner's own, on top of any share or token restrictions. A null limit means uncapped. The duration limit + * does not apply to live control; disallow live control to bound it. */ export const shockerSetShockerPermissions = ( options: Options @@ -1411,6 +1420,36 @@ export const shareLinksPauseShocker = ( }, }); +/** + * Set, change or remove the password of a public share + * + * Setting or changing the password disconnects everyone currently using the share; they have to enter the + * new one. Removing it keeps them connected. + */ +export const shareLinksSetPublicSharePassword = ( + options: Options +): RequestResult< + ShareLinksSetPublicSharePasswordResponses, + ShareLinksSetPublicSharePasswordErrors, + ThrowOnError, + 'data' +> => + (options.client ?? client).put< + ShareLinksSetPublicSharePasswordResponses, + ShareLinksSetPublicSharePasswordErrors, + ThrowOnError, + 'data' + >({ + responseTransformer: shareLinksSetPublicSharePasswordResponseTransformer, + responseStyle: 'data', + url: '/1/shares/links/{publicShareId}/password', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers, + }, + }); + export const sessionsDeleteSession = ( options: Options ): RequestResult< @@ -1529,6 +1568,33 @@ export const publicGetPublicShareBySlug = ( ...options, }); +/** + * Unlocks a password-protected public share. + */ +export const publicUnlockPublicShare = ( + options: Options +): RequestResult< + PublicUnlockPublicShareResponses, + PublicUnlockPublicShareErrors, + ThrowOnError, + 'data' +> => + (options.client ?? client).post< + PublicUnlockPublicShareResponses, + PublicUnlockPublicShareErrors, + ThrowOnError, + 'data' + >({ + responseTransformer: publicUnlockPublicShareResponseTransformer, + responseStyle: 'data', + url: '/1/public/shares/links/{publicShareId}/unlock', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers, + }, + }); + /** * Lets a service holding many users keep their lifetime control stats in sync with a single call per tick. * Returns the lifetime totals of every requested user whose stats changed since the given cursor. diff --git a/src/lib/api/internal/generated/transformers.gen.ts b/src/lib/api/internal/generated/transformers.gen.ts index 09419260..fcb7927e 100644 --- a/src/lib/api/internal/generated/transformers.gen.ts +++ b/src/lib/api/internal/generated/transformers.gen.ts @@ -28,10 +28,12 @@ import type { PublicGetOnlineDevicesStatisticsResponse, PublicGetPublicShareBySlugResponse, PublicGetPublicShareResponse, + PublicUnlockPublicShareResponse, SessionsGetSelfSessionResponse, SessionsListSessionsResponse, ShareLinksEditPublicShareResponse, ShareLinksListResponse, + ShareLinksSetPublicSharePasswordResponse, ShockerGetAllShockerLogsResponse, ShockerGetShockerByIdResponse, ShockerGetShockerLogsResponse, @@ -362,6 +364,13 @@ export const shareLinksEditPublicShareResponseTransformer = async ( return data; }; +export const shareLinksSetPublicSharePasswordResponseTransformer = async ( + data: any +): Promise => { + data = ownPublicShareResponseSchemaResponseTransformer(data); + return data; +}; + const loginSessionResponseSchemaResponseTransformer = (data: any) => { data.created = Temporal.Instant.from(data.created); data.expires = Temporal.Instant.from(data.expires); @@ -429,6 +438,18 @@ export const publicGetPublicShareBySlugResponseTransformer = async ( return data; }; +const publicShareUnlockResponseSchemaResponseTransformer = (data: any) => { + data.expiresOn = Temporal.Instant.from(data.expiresOn); + return data; +}; + +export const publicUnlockPublicShareResponseTransformer = async ( + data: any +): Promise => { + data = publicShareUnlockResponseSchemaResponseTransformer(data); + return data; +}; + const userControlStatTotalsSchemaResponseTransformer = (data: any) => { data.received = data.received.map((item: any) => controlStatTotalsSchemaResponseTransformer(item) diff --git a/src/lib/api/internal/generated/types.gen.ts b/src/lib/api/internal/generated/types.gen.ts index 7a51a49e..a7e7a4c8 100644 --- a/src/lib/api/internal/generated/types.gen.ts +++ b/src/lib/api/internal/generated/types.gen.ts @@ -1128,6 +1128,7 @@ export type OwnPublicShareResponse = { slug: null | string; createdOn: Temporal.Instant; expiresOn?: null | Temporal.Instant; + hasPassword: boolean; }; export type OwnUserProfileResponse = { @@ -1281,6 +1282,10 @@ export type PublicShareCreate = { * Custom URL segment, reachable at /u/{username}/{slug}. Unique per owner. */ slug?: null | string; + /** + * Optional password visitors must enter before they can see or control the shockers. + */ + password?: null | string; }; export type PublicShareDevice = { @@ -1304,6 +1309,13 @@ export type PublicShareEditShocker = { cooldown?: null | number; }; +export type PublicSharePasswordSet = { + /** + * The new password, or null to remove it. Setting or changing it disconnects everyone currently using the share. + */ + password: null | string; +}; + export type PublicShareResponse = { id: string; name: string; @@ -1311,6 +1323,14 @@ export type PublicShareResponse = { createdOn: Temporal.Instant; expiresOn?: null | Temporal.Instant; author: PublicShareAuthor; + /** + * Visitors have to enter a password before they can see or control the shockers. + */ + passwordProtected: boolean; + /** + * The share is password protected and this request did not unlock it: IList<PublicShareDevice> PublicShareResponse.Devices is empty. + */ + passwordRequired: boolean; devices?: Array; }; @@ -1334,6 +1354,19 @@ export type PublicShareShocker = { paused: number; }; +export type PublicShareUnlock = { + password: string; +}; + +export type PublicShareUnlockResponse = { + /** + * Send it in the OpenShockPublicShareUnlock header when loading the share, and as the unlockToken query + * parameter when connecting to its hub. Invalid once the password is changed. + */ + token: string; + expiresOn: Temporal.Instant; +}; + export type PublicUserProfileDetails = { pronouns: null | string; bio: null | string; @@ -1344,6 +1377,7 @@ export type PublicUserProfilePublicShare = { id: string; name: string; slug: null | string; + passwordProtected: boolean; }; export type PublicUserProfileResponse = { @@ -1473,6 +1507,9 @@ export type ShockerControlStats = { export type ShockerLimits = { intensity: null | number; + /** + * Maximum duration in milliseconds. Does not apply to live control, which has no fixed duration. + */ duration: null | number; }; @@ -3054,6 +3091,35 @@ export type ShareLinksPauseShockerResponses = { export type ShareLinksPauseShockerResponse = ShareLinksPauseShockerResponses[keyof ShareLinksPauseShockerResponses]; +export type ShareLinksSetPublicSharePasswordData = { + body: PublicSharePasswordSet; + path: { + publicShareId: string; + }; + query?: never; + url: '/1/shares/links/{publicShareId}/password'; +}; + +export type ShareLinksSetPublicSharePasswordErrors = { + /** + * Public share not found or does not belong to you + */ + 404: OpenShockProblem; +}; + +export type ShareLinksSetPublicSharePasswordError = + ShareLinksSetPublicSharePasswordErrors[keyof ShareLinksSetPublicSharePasswordErrors]; + +export type ShareLinksSetPublicSharePasswordResponses = { + /** + * The updated public share + */ + 200: OwnPublicShareResponse; +}; + +export type ShareLinksSetPublicSharePasswordResponse = + ShareLinksSetPublicSharePasswordResponses[keyof ShareLinksSetPublicSharePasswordResponses]; + export type SessionsDeleteSessionData = { body?: never; path: { @@ -3162,6 +3228,12 @@ export type PublicGetUserProfileResponse = export type PublicGetPublicShareData = { body?: never; + headers?: { + /** + * The token from unlocking a password-protected share. + */ + OpenShockPublicShareUnlock?: string; + }; path: { publicShareId: string; }; @@ -3191,6 +3263,12 @@ export type PublicGetPublicShareResponse = export type PublicGetPublicShareBySlugData = { body?: never; + headers?: { + /** + * The token from unlocking a password-protected share. + */ + OpenShockPublicShareUnlock?: string; + }; path: { username: string; slug: string; @@ -3219,6 +3297,47 @@ export type PublicGetPublicShareBySlugResponses = { export type PublicGetPublicShareBySlugResponse = PublicGetPublicShareBySlugResponses[keyof PublicGetPublicShareBySlugResponses]; +export type PublicUnlockPublicShareData = { + body: PublicShareUnlock; + path: { + publicShareId: string; + }; + query?: never; + url: '/1/public/shares/links/{publicShareId}/unlock'; +}; + +export type PublicUnlockPublicShareErrors = { + /** + * The public share has no password. + */ + 400: OpenShockProblem; + /** + * The password was incorrect. + */ + 401: OpenShockProblem; + /** + * The public share does not exist. + */ + 404: OpenShockProblem; + /** + * Too many incorrect passwords were entered for this public share. + */ + 429: OpenShockProblem; +}; + +export type PublicUnlockPublicShareError = + PublicUnlockPublicShareErrors[keyof PublicUnlockPublicShareErrors]; + +export type PublicUnlockPublicShareResponses = { + /** + * The password was correct. + */ + 200: PublicShareUnlockResponse; +}; + +export type PublicUnlockPublicShareResponse = + PublicUnlockPublicShareResponses[keyof PublicUnlockPublicShareResponses]; + export type IntegrationsGetControlStatChangesData = { body: ControlStatChangesRequest; path?: never; diff --git a/src/lib/components/public-share/ControlView.svelte b/src/lib/components/public-share/ControlView.svelte index 9d7c1396..725ac980 100644 --- a/src/lib/components/public-share/ControlView.svelte +++ b/src/lib/components/public-share/ControlView.svelte @@ -28,11 +28,15 @@ interface Props { shareLinkRoot: PublicShareResponse; guestName: string | null; + unlockToken?: string | null; + onConnectionLost?: () => void; } - const { shareLinkRoot, guestName }: Props = $props(); + const { shareLinkRoot, guestName, unlockToken = null, onConnectionLost }: Props = $props(); - const shareLinkSignalr = untrack(() => new ShareLinkSignalr(shareLinkRoot.id, guestName)); + const shareLinkSignalr = untrack( + () => new ShareLinkSignalr(shareLinkRoot.id, guestName, unlockToken, onConnectionLost) + ); onMount(() => { shareLinkSignalr.initializeSignalR(); diff --git a/src/lib/components/public-share/PublicShareView.svelte b/src/lib/components/public-share/PublicShareView.svelte index 6a770775..bc669a3b 100644 --- a/src/lib/components/public-share/PublicShareView.svelte +++ b/src/lib/components/public-share/PublicShareView.svelte @@ -1,14 +1,25 @@ -{#if entered} - +{#if checkingStoredToken} + +{:else if entered} + {:else}
- {#if showAuthorProfile && share.author.profile} + {#if showAuthorProfile && current.author.profile} {/if} -

{share.name}

- {m.public_share_view_desc()} +

{current.name}

+ + {current.passwordRequired ? m.public_share_password_desc() : m.public_share_view_desc()} +
- {#if enterAsGuestClicked} + {#if current.passwordRequired} + {#if accessLost} +

+ {m.public_share_password_changed()} +

+ {/if} +
+ + {#if passwordError} +

{passwordError}

+ {/if} + +
+ {:else if enterAsGuestClicked} + {#if share.passwordProtected} + + {/if} + +
diff --git a/src/routes/(app)/shares/public/dialog-publicshare-create.svelte b/src/routes/(app)/shares/public/dialog-publicshare-create.svelte index 07204dc3..5eed223e 100644 --- a/src/routes/(app)/shares/public/dialog-publicshare-create.svelte +++ b/src/routes/(app)/shares/public/dialog-publicshare-create.svelte @@ -9,6 +9,12 @@ import { toast } from 'svelte-sonner'; import SlugInput from '#lib/components/public-share/SlugInput.svelte'; import { isValidSlug, normalizeSlug } from '#lib/utils/slug.js'; + import { + isValidSharePassword, + PUBLIC_SHARE_PASSWORD_MAX_LENGTH, + PUBLIC_SHARE_PASSWORD_MIN_LENGTH, + } from '#lib/utils/public-share-unlock.js'; + import { PasswordInput } from '@openshock/svelte-core/components/input'; interface Props { open: boolean; @@ -21,25 +27,33 @@ let expireOption = $state('never'); let expireInstant = $state(null); let slug = $state(''); + let password = $state(''); const normalizedSlug = $derived(normalizeSlug(slug)); const slugValid = $derived(normalizedSlug === '' || isValidSlug(normalizedSlug)); + const passwordValid = $derived(password === '' || isValidSharePassword(password)); const expiryValid = $derived(expireOption !== 'custom' || expireInstant !== null); let submitting = $state(false); async function createShareLink() { - if (submitting || !slugValid || !expiryValid) return; + if (submitting || !slugValid || !expiryValid || !passwordValid) return; submitting = true; try { await shareLinksCreatePublicShare({ - body: { name, expiresOn: expireInstant ?? undefined, slug: normalizedSlug || null }, + body: { + name, + expiresOn: expireInstant ?? undefined, + slug: normalizedSlug || null, + password: password || null, + }, }); onCreated(); toast.success(m.public_share_toast_created()); open = false; name = ''; slug = ''; + password = ''; expireOption = 'never'; expireInstant = null; } catch (error) { @@ -58,10 +72,27 @@ + - diff --git a/src/routes/shares/public/[shareId=guid]/+page.svelte b/src/routes/shares/public/[shareId=guid]/+page.svelte index 5e82c0bb..e47da290 100644 --- a/src/routes/shares/public/[shareId=guid]/+page.svelte +++ b/src/routes/shares/public/[shareId=guid]/+page.svelte @@ -35,7 +35,9 @@ {#await details}

{m.public_share_view_loading()}

{:then share} - + {#key share.id} + + {/key} {:catch error}

{error.message}

{/await} diff --git a/src/routes/u/[username]/+page.svelte b/src/routes/u/[username]/+page.svelte index 1b6cc072..239a9883 100644 --- a/src/routes/u/[username]/+page.svelte +++ b/src/routes/u/[username]/+page.svelte @@ -73,7 +73,9 @@ profile={result.response.profile} /> {#if result.share.status === 'loaded'} - + {#key result.share.share.id} + + {/key} {:else if result.share.status === 'failed'}

{m.public_profile_share_failed()}

From 35b3e858c46d07d9ffedb288cde3560c273865cc Mon Sep 17 00:00:00 2001 From: LucHeart Date: Thu, 3 Dec 2026 17:32:01 +0100 Subject: [PATCH 2/3] fix: send visitors to the password prompt when a password is added to an open public share --- e2e/integration/public-share-password.spec.ts | 12 ++++++++++++ messages/en.json | 2 +- .../components/public-share/PublicShareView.svelte | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/e2e/integration/public-share-password.spec.ts b/e2e/integration/public-share-password.spec.ts index 2c70d32d..9791f0c6 100644 --- a/e2e/integration/public-share-password.spec.ts +++ b/e2e/integration/public-share-password.spec.ts @@ -65,6 +65,18 @@ test.describe('public share passwords', () => { await visitor.reload(); await expect(visitor.getByRole('button', { name: 'Enter as Guest' })).toBeVisible(); + // Adding a password sends a visitor who is in control back to the password prompt + await visitor.getByRole('button', { name: 'Enter as Guest' }).click(); + await visitor.getByPlaceholder('Guest Name').fill('Visitor'); + await visitor.getByRole('button', { name: 'Enter', exact: true }).click(); + await expect(visitor.getByText('This public share is password protected.')).toBeHidden(); + + await passwordCard.getByLabel('Password', { exact: true }).fill('another secret'); + await passwordCard.getByRole('button', { name: 'Set password' }).click(); + await expect(page.getByText('Password saved')).toBeVisible(); + + await expect(visitor.getByText('The owner set a new password. Enter it to continue.')).toBeVisible(); + await anon.close(); }); }); diff --git a/messages/en.json b/messages/en.json index 94b3021f..721168e5 100644 --- a/messages/en.json +++ b/messages/en.json @@ -902,7 +902,7 @@ "public_share_password_desc": "This public share is password protected.", "public_share_password_placeholder": "Enter the password", "public_share_password_unlock": "Unlock", - "public_share_password_changed": "The password was changed. Enter the new one to continue.", + "public_share_password_changed": "The owner set a new password. Enter it to continue.", "public_share_settings_title": "Settings", "public_share_settings_desc": "Name, custom URL and expiry of this public share.", "public_share_toast_settings_saved": "Public share updated", diff --git a/src/lib/components/public-share/PublicShareView.svelte b/src/lib/components/public-share/PublicShareView.svelte index bc669a3b..07448057 100644 --- a/src/lib/components/public-share/PublicShareView.svelte +++ b/src/lib/components/public-share/PublicShareView.svelte @@ -90,9 +90,9 @@ } } - /** The hub dropped us: if the password changed, go back to the password prompt. */ + /** The hub dropped us: if a password was set or changed, go back to the password prompt. */ async function onConnectionLost() { - if (!current.passwordProtected || refreshing) return; + if (refreshing) return; refreshing = true; try { await refresh(); From 9329cbcedc22a48dfad3d16a3b71c10f0a850eaa Mon Sep 17 00:00:00 2001 From: LucHeart Date: Thu, 3 Dec 2026 17:32:18 +0100 Subject: [PATCH 3/3] style: format public share password spec --- e2e/integration/public-share-password.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e/integration/public-share-password.spec.ts b/e2e/integration/public-share-password.spec.ts index 9791f0c6..dedc5183 100644 --- a/e2e/integration/public-share-password.spec.ts +++ b/e2e/integration/public-share-password.spec.ts @@ -75,7 +75,9 @@ test.describe('public share passwords', () => { await passwordCard.getByRole('button', { name: 'Set password' }).click(); await expect(page.getByText('Password saved')).toBeVisible(); - await expect(visitor.getByText('The owner set a new password. Enter it to continue.')).toBeVisible(); + await expect( + visitor.getByText('The owner set a new password. Enter it to continue.') + ).toBeVisible(); await anon.close(); });