Skip to content

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

Refactor unlock success flow (#957)

Leendert de Borst0e803205c03e
diff --git a/apps/browser-extension/src/entrypoints/popup/App.tsx b/apps/browser-extension/src/entrypoints/popup/App.tsx
index 3353b8d36..3e7980193 100644
--- a/apps/browser-extension/src/entrypoints/popup/App.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/App.tsx
@@ -53,7 +53,7 @@ const App: React.FC = () => {
{ path: '/reinitialize', element: <Reinitialize />, showBackButton: false },
{ path: '/login', element: <Login />, showBackButton: false },
{ path: '/unlock', element: <Unlock />, showBackButton: false },
- { path: '/unlock-success', element: <UnlockSuccess onClose={() => window.location.search = ''} />, showBackButton: false },
+ { path: '/unlock-success', element: <UnlockSuccess />, showBackButton: false },
{ path: '/upgrade', element: <Upgrade />, showBackButton: false },
{ path: '/auth-settings', element: <AuthSettings />, showBackButton: true, title: 'Settings' },
{ path: '/credentials', element: <CredentialsList />, showBackButton: false },
diff --git a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
index 4eb5fa164..b0ed98207 100644
--- a/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/context/NavigationContext.tsx
@@ -43,7 +43,7 @@ export const NavigationProvider: React.FC<{ children: React.ReactNode }> = ({ ch
*/
const storeCurrentPage = useCallback(async (): Promise<void> => {
// Pages that are not allowed to be stored as these are auth conditional pages.
- const notAllowedPaths = ['/', '/reinitialize', '/login', '/unlock', '/unlock-success', '/auth-settings', '/upgrade'];
+ const notAllowedPaths = ['/', '/reinitialize', '/login', '/unlock', '/unlock-success', '/auth-settings', '/upgrade', '/logout'];
// Only store the page if we're fully initialized and don't need auth
if (isFullyInitialized && !requiresAuth && !notAllowedPaths.includes(location.pathname)) {
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx
index d42de9e57..132b1b493 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/Login.tsx
@@ -169,8 +169,8 @@ const Login: React.FC = () => {
return;
}
- // Navigate to credentials page after successful login
- navigate('/credentials', { replace: true });
+ // Navigate to reinitialize page which will take care of the proper redirect.
+ navigate('/reinitialize', { replace: true });
// Show app.
hideLoading();
@@ -245,8 +245,8 @@ const Login: React.FC = () => {
return;
}
- // Navigate to credentials page after successful login
- navigate('/credentials', { replace: true });
+ // Navigate to reinitialize page which will take care of the proper redirect.
+ navigate('/reinitialize', { replace: true });
// Reset 2FA state and login response as it's no longer needed
setTwoFactorRequired(false);
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
index b22f99cd2..59ad97245 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/Reinitialize.tsx
@@ -133,7 +133,6 @@ const Reinitialize: React.FC = () => {
* Handle upgrade required.
*/
onUpgradeRequired: () => {
- // This shouldn't happen anymore since we check in DbContext
navigate('/upgrade', { replace: true });
setIsInitialLoading(false);
}
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/UnlockSuccess.tsx b/apps/browser-extension/src/entrypoints/popup/pages/UnlockSuccess.tsx
index de751f12f..2393dc41f 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/UnlockSuccess.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/UnlockSuccess.tsx
@@ -1,45 +1,55 @@
import React from 'react';
+import { useNavigate } from 'react-router-dom';
/**
* Unlock success component shown when the vault is successfully unlocked in a separate popup
* asking the user if they want to close the popup.
*/
-const UnlockSuccess: React.FC<{
- onClose: () => void;
-}> = ({ onClose }) => (
- <div className="flex flex-col items-center justify-center p-6 text-center">
- <div className="mb-4 text-green-600 dark:text-green-400">
- <svg className="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
- </svg>
- </div>
- <h2 className="text-xl font-semibold mb-4 text-gray-900 dark:text-white">
- Your vault is successfully unlocked
- </h2>
- <p className="mb-6 text-gray-600 dark:text-gray-400">
- You can now use autofill in login forms in your browser.
- </p>
- <div className="space-y-3 w-full">
- <button
- onClick={() => window.close()}
- className="w-full px-4 py-2 text-white bg-primary-600 rounded hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2"
- >
- Close this popup
- </button>
- <button
- onClick={() => {
- // Remove mode=inline from URL before closing
- const url = new URL(window.location.href);
- url.searchParams.delete('mode');
- window.history.replaceState({}, '', url);
- onClose();
- }}
- className="w-full px-4 py-2 text-gray-700 bg-gray-100 rounded hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"
- >
- Browse vault contents
- </button>
+const UnlockSuccess: React.FC = () => {
+ const navigate = useNavigate();
+
+ /**
+ * Handle browsing vault contents - navigate to credentials page and reset mode parameter
+ */
+ const handleBrowseVaultContents = (): void => {
+ // Remove mode=inline from URL before navigating
+ const url = new URL(window.location.href);
+ url.searchParams.delete('mode');
+ window.history.replaceState({}, '', url);
+
+ // Navigate to credentials page
+ navigate('/credentials');
+ };
+
+ return (
+ <div className="flex flex-col items-center justify-center p-6 text-center">
+ <div className="mb-4 text-green-600 dark:text-green-400">
+ <svg className="w-12 h-12 mx-auto" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
+ </svg>
+ </div>
+ <h2 className="text-xl font-semibold mb-4 text-gray-900 dark:text-white">
+ Your vault is successfully unlocked
+ </h2>
+ <p className="mb-6 text-gray-600 dark:text-gray-400">
+ You can now use autofill in login forms in your browser.
+ </p>
+ <div className="space-y-3 w-full">
+ <button
+ onClick={() => window.close()}
+ className="w-full px-4 py-2 text-white bg-primary-600 rounded hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2"
+ >
+ Close this popup
+ </button>
+ <button
+ onClick={handleBrowseVaultContents}
+ className="w-full px-4 py-2 text-gray-700 bg-gray-100 rounded hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600"
+ >
+ Browse vault contents
+ </button>
+ </div>
</div>
- </div>
-);
+ );
+};
export default UnlockSuccess;