Skip to content

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

Add try catch for incorrect status login call (#601)

Leendert de Borst65d1ca156420
diff --git a/browser-extensions/chrome/src/app/App.tsx b/browser-extensions/chrome/src/app/App.tsx
index 71532b4ab..ca682ab0f 100644
--- a/browser-extensions/chrome/src/app/App.tsx
+++ b/browser-extensions/chrome/src/app/App.tsx
@@ -58,7 +58,8 @@ const App: React.FC = () => {
useEffect(() => {
if (authContext.globalMessage) {
setMessage(authContext.globalMessage);
- authContext.clearGlobalMessage();
+ } else {
+ setMessage(null);
}
}, [authContext, authContext.globalMessage]);
diff --git a/browser-extensions/chrome/src/app/pages/Login.tsx b/browser-extensions/chrome/src/app/pages/Login.tsx
index cf01353c9..13391d693 100644
--- a/browser-extensions/chrome/src/app/pages/Login.tsx
+++ b/browser-extensions/chrome/src/app/pages/Login.tsx
@@ -60,6 +60,9 @@ const Login: React.FC = () => {
try {
showLoading();
+ // Clear global message if set with every login attempt.
+ authContext.clearGlobalMessage();
+
// Use the srpUtil instance instead of the imported singleton
const loginResponse = await srpUtil.initiateLogin(credentials.username);
@@ -127,9 +130,8 @@ const Login: React.FC = () => {
// Show app.
hideLoading();
- } catch (err) {
- setError('Login failed. Please check your credentials and try again.');
- console.error('Login error:', err);
+ } catch {
+ setError('Could not reach AliasVault server. Please try again later or contact support if the problem persists.');
hideLoading();
}
};
diff --git a/browser-extensions/chrome/src/shared/WebApiService.ts b/browser-extensions/chrome/src/shared/WebApiService.ts
index e946225e0..c5dc1c173 100644
--- a/browser-extensions/chrome/src/shared/WebApiService.ts
+++ b/browser-extensions/chrome/src/shared/WebApiService.ts
@@ -219,13 +219,29 @@ export class WebApiService {
* Calls the status endpoint to check if the auth tokens are still valid, app is supported and the vault is up to date.
*/
public async getStatus(): Promise<StatusResponse> {
- return await this.get<StatusResponse>('Auth/status');
+ try {
+ return await this.get<StatusResponse>('Auth/status');
+ } catch {
+ /**
+ * If the status endpoint is not available, return a default status response which will trigger
+ * a logout and error message.
+ */
+ return {
+ clientVersionSupported: true,
+ serverVersion: '0.0.0',
+ vaultRevision: 0
+ };
+ }
}
/**
* Validates the status response and returns an error message if validation fails.
*/
public validateStatusResponse(statusResponse: StatusResponse): string | null {
+ if (statusResponse.serverVersion === '0.0.0') {
+ return 'The AliasVault server is not available. Please try again later or contact support if the problem persists.';
+ }
+
if (!statusResponse.clientVersionSupported) {
return 'This version of the AliasVault browser extension is outdated. Please update your browser extension to the latest version.';
}