From 94cafc26abb3bf651da87dcda5f89348c612a4e6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 25 Jan 2026 18:32:46 +0000 Subject: [PATCH] Fix storage credentials persistence on profile switch This change ensures that cloud storage credentials are not leaked between Nostr profiles when switching accounts in the UI. Changes: - Imported `storageService` in `js/app.js` to enable the `bitvid:auth-changed` event listener to correctly lock the previous profile's storage session. - Updated `ProfileModalController.populateStoragePane` to explicitly clear the storage form before loading new data. - Enhanced `ProfileModalController.handleClearStorage` to fully reset the form state, including the provider selection and visibility toggles. Verified with a reproduction script (`reproduce_storage_isolation.mjs`) that `StorageService` correctly isolates data by pubkey at the backend level. The UI fixes address the frontend persistence issue. --- js/app.js | 1 + js/ui/profileModalController.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/js/app.js b/js/app.js index b5290d46..340394b6 100644 --- a/js/app.js +++ b/js/app.js @@ -53,6 +53,7 @@ import { } from "./feedEngine/index.js"; import watchHistoryService from "./watchHistoryService.js"; import r2Service from "./services/r2Service.js"; +import storageService from "./services/storageService.js"; import { getVideoNoteErrorMessage, normalizeVideoNotePayload, diff --git a/js/ui/profileModalController.js b/js/ui/profileModalController.js index c888d6cb..409e9795 100644 --- a/js/ui/profileModalController.js +++ b/js/ui/profileModalController.js @@ -8974,6 +8974,8 @@ export class ProfileModalController { const storageService = this.services.storageService; const pubkey = this.normalizeHexPubkey(this.getActivePubkey()); + this.handleClearStorage(); + if (!pubkey) { // Not logged in if (this.storageUnlockSection) this.storageUnlockSection.classList.add("hidden"); @@ -9300,6 +9302,8 @@ export class ProfileModalController { this.storageBucketInput.value = ""; this.storagePrefixInput.value = ""; this.storageDefaultInput.checked = false; + this.storageProviderInput.value = "cloudflare_r2"; + this.updateStorageFormVisibility(); this.setStorageFormStatus("", "info"); }