Skip to content

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

Tweak browser extension server connection error flow

Leendert de Borst18ee97f6e5af
diff --git a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts
index ec5b294d8..be2b67e3d 100644
--- a/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts
+++ b/apps/browser-extension/src/entrypoints/popup/hooks/useVaultSync.ts
@@ -74,7 +74,9 @@ export const useVaultSync = () : {
// Check if server is actually available, 0.0.0 indicates connection error which triggers offline mode.
if (statusResponse.serverVersion === '0.0.0') {
- // Offline mode is not implemented for browser extension yet, let it fail below due to the validateStatusResponse check.
+ // Offline mode is not implemented for browser extension yet, so logout the user.
+ onError?.(t('common.errors.serverNotAvailable'));
+ return false;
}
const statusError = webApi.validateStatusResponse(statusResponse);
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
index c1fd249c9..204e7d3ad 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx
@@ -42,20 +42,29 @@ const Unlock: React.FC = () => {
const [error, setError] = useState<string | null>(null);
const { showLoading, hideLoading, setIsInitialLoading } = useLoading();
- useEffect(() => {
- /**
- * Make status call to API which acts as health check.
- * This runs only once during component mount.
- */
- const checkStatus = async () : Promise<void> => {
- const statusResponse = await webApi.getStatus();
- const statusError = webApi.validateStatusResponse(statusResponse);
- if (statusError !== null) {
- await app.logout(t('common.errors.' + statusError));
- }
- setIsInitialLoading(false);
- };
+ /**
+ * Make status call to API which acts as health check.
+ * This runs only once during component mount.
+ */
+ const checkStatus = async () : Promise<boolean> => {
+ const statusResponse = await webApi.getStatus();
+ const statusError = webApi.validateStatusResponse(statusResponse);
+
+ if (statusResponse.serverVersion === '0.0.0') {
+ setError(t('common.errors.serverNotAvailable'));
+ return false;
+ }
+ if (statusError !== null) {
+ await app.logout(t('common.errors.' + statusError));
+ return false;
+ }
+
+ setIsInitialLoading(false);
+ return true;
+ };
+
+ useEffect(() => {
checkStatus();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); // Only run once on mount
@@ -85,6 +94,12 @@ const Unlock: React.FC = () => {
setError(null);
showLoading();
+ const isStatusOk = await checkStatus();
+ if (!isStatusOk) {
+ hideLoading();
+ return;
+ }
+
try {
// 1. Initiate login to get salt and server ephemeral
const loginResponse = await srpUtil.initiateLogin(authContext.username!);
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialsList.tsx b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialsList.tsx
index 423d43aeb..704031f70 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialsList.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/credentials/CredentialsList.tsx
@@ -72,7 +72,6 @@ const CredentialsList: React.FC = () => {
*/
onError: async (error) => {
console.error('Error syncing vault:', error);
- await app.logout('Error while syncing vault, please re-authenticate.');
},
});
} catch (err) {