Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Clear pending redirect when opening main popup without redirect (#520)

Leendert de Borst240a0854be82
diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsx
index 7642acf8c..a629d1b01 100644
--- a/apps/browser-extension/src/entrypoints/popup/App.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx
@@ -36,6 +36,7 @@ import Settings from '@/entrypoints/popup/pages/settings/Settings';
import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import '@/entrypoints/popup/style.css';
+import { clearPendingRedirectUrl } from './hooks/useVaultLockRedirect';
/**
* Available layout types for different page contexts.
@@ -199,6 +200,16 @@ const App: React.FC = () => {
};
}, []);
+ /**
+ * On initial load, clear any stale pending redirect URL if popup was not opened with a specific hash path.
+ */
+ useEffect(() => {
+ const hasHashPath = window.location.hash && window.location.hash !== '#/' && window.location.hash !== '#';
+ if (!hasHashPath) {
+ clearPendingRedirectUrl();
+ }
+ }, []);
+
/**
* Print global message if it exists.
*/
diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultLockRedirect.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultLockRedirect.ts
index 4c5cb8175..0c27e10b5 100644
--- a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultLockRedirect.ts
+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultLockRedirect.ts
@@ -3,9 +3,9 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { useDb } from '@/entrypoints/popup/context/DbContext';
-import { storage } from '#imports';
+import { PENDING_REDIRECT_URL_KEY } from '@/utils/Constants';
-const PENDING_REDIRECT_URL_KEY = 'session:pendingRedirectUrl';
+import { storage } from '#imports';
/**
* Hook to handle vault lock redirects.
@@ -52,3 +52,11 @@ export async function consumePendingRedirectUrl(): Promise<string | null> {
}
return url;
}
+
+/**
+ * Clear the pending redirect URL from storage.
+ * Used when popup is opened without a specific hash path to clear stale redirects.
+ */
+export async function clearPendingRedirectUrl(): Promise<void> {
+ await storage.removeItem(PENDING_REDIRECT_URL_KEY);
+}
diff --git a/apps/browser-extension/src/utils/Constants.ts b/apps/browser-extension/src/utils/Constants.ts
index e374e4ace..61f51a305 100644
--- a/apps/browser-extension/src/utils/Constants.ts
+++ b/apps/browser-extension/src/utils/Constants.ts
@@ -8,6 +8,7 @@ export const AUTO_LOCK_TIMEOUT_KEY = 'local:aliasvault_auto_lock_timeout';
export const AUTOFILL_MATCHING_MODE_KEY = 'local:aliasvault_autofill_matching_mode';
export const PASSKEY_PROVIDER_ENABLED_KEY = 'local:aliasvault_passkey_provider_enabled';
export const PASSKEY_DISABLED_SITES_KEY = 'local:aliasvault_passkey_disabled_sites';
+export const PENDING_REDIRECT_URL_KEY = 'session:pendingRedirectUrl';
// TODO: store these settings in the actual vault when updating the datamodel for roadmap v1.0.
export const CUSTOM_EMAIL_HISTORY_KEY = 'local:aliasvault_custom_email_history';