Clear PIN data on logout (#1340)

This commit is contained in:
Leendert de Borst
2025-11-13 07:03:04 +01:00
committed by Leendert de Borst
parent 039e63f5c8
commit ccf923bc98
2 changed files with 17 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import { sendMessage } from 'webext-bridge/popup';
import { useDb } from '@/entrypoints/popup/context/DbContext';
import { VAULT_LOCKED_DISMISS_UNTIL_KEY } from '@/utils/Constants';
import { removeAndDisablePin } from '@/utils/PinUnlockService';
import { storage } from '#imports';
@@ -73,6 +74,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
await storage.removeItems(['local:username', 'local:accessToken', 'local:refreshToken']);
dbContext?.clearDatabase();
// Clear PIN unlock data (if any)
try {
await removeAndDisablePin();
} catch (error) {
console.error('Failed to remove PIN data:', error);
// Non-fatal error - continue with logout
}
// Set local storage global message that will be shown on the login page.
if (errorMessage) {
setGlobalMessage(errorMessage);

View File

@@ -205,6 +205,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
// Non-fatal error - continue with logout
}
// Clear PIN unlock data (if any)
try {
await NativeVaultManager.removeAndDisablePin();
} catch (error) {
console.error('Failed to remove PIN data:', error);
// Non-fatal error - continue with logout
}
// Clear from native layer
await NativeVaultManager.clearUsername();
await NativeVaultManager.clearAuthTokens();