Skip to content

Commit

Permalink
Improve logout reset (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanedirt committed Feb 13, 2025
1 parent 867b37a commit 2013f48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions browser-extensions/chrome/src/app/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { LoadingProvider } from './context/LoadingContext';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
root.render(
<AuthProvider>
<DbProvider>
<DbProvider>
<AuthProvider>
<WebApiProvider>
<LoadingProvider>
<App />
</LoadingProvider>
</WebApiProvider>
</DbProvider>
</AuthProvider>
</AuthProvider>
</DbProvider>
);
3 changes: 3 additions & 0 deletions browser-extensions/chrome/src/app/context/AuthContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { createContext, useContext, useState, useEffect } from 'react';
import { useDb } from './DbContext';

type AuthContextType = {
isLoggedIn: boolean;
Expand All @@ -23,6 +24,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
const [isInitialized, setIsInitialized] = useState(false);
const [username, setUsername] = useState<string | null>(null);
const [globalMessage, setGlobalMessage] = useState<string | null>(null);
const dbContext = useDb();

/**
* Check for tokens in chrome storage on initial load.
Expand Down Expand Up @@ -63,6 +65,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
const logout = async (errorMessage?: string) : Promise<void> => {
await chrome.runtime.sendMessage({ type: 'CLEAR_VAULT' });
await chrome.storage.local.remove(['username', 'accessToken', 'refreshToken']);
await dbContext?.clearDatabase();

// Set local storage global message that will be shown on the login page.
if (errorMessage) {
Expand Down
2 changes: 2 additions & 0 deletions browser-extensions/chrome/src/contentScript/Popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ function createCredentialList(credentials: Credential[]): HTMLElement[] {
noMatches.style.cssText = `
padding-left: 10px;
padding-top: 8px;
padding-bottom: 8px;
font-size: 14px;
color: ${isDarkMode() ? '#9ca3af' : '#6b7280'};
font-style: italic;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
Expand Down

0 comments on commit 2013f48

Please sign in to comment.