Skip to content

Commit a60e5d3

Browse files
committed
fix admin sign out button, show user email in directory if there is no name
1 parent 25ca27b commit a60e5d3

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

frontend/src/APIClients/authAPIClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from '../utils/LocalStorageUtils';
2020
import { signInWithEmailAndPassword, applyActionCode, checkActionCode } from 'firebase/auth';
2121
import { auth } from '@/config/firebase';
22+
import { clearAuthCache } from '@/hooks/useAuthGuard';
2223

2324
// Validation helper
2425
const validateEmail = (email: string): boolean => {
@@ -158,6 +159,7 @@ export const logout = async (): Promise<boolean> => {
158159
} finally {
159160
// Always clear localStorage and sign out from Firebase regardless of backend API success/failure
160161
localStorage.removeItem(AUTHENTICATED_USER_KEY);
162+
clearAuthCache();
161163
try {
162164
await firebaseSignOut(auth);
163165
} catch (firebaseError) {

frontend/src/components/admin/AdminHeader.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useRouter } from 'next/router';
55
import { FiFolder, FiLoader, FiLogOut } from 'react-icons/fi';
66
import { LabelSmall } from '@/components/ui/text-styles';
77
import { COLORS, shadow } from '@/constants/colors';
8+
import { logout } from '@/APIClients/authAPIClient';
89

910
export const AdminHeader: React.FC = () => {
1011
const router = useRouter();
@@ -17,6 +18,10 @@ export const AdminHeader: React.FC = () => {
1718
router.push('/admin/directory');
1819
};
1920

21+
const handleSignOut = async () => {
22+
await logout();
23+
};
24+
2025
return (
2126
<Box
2227
w="full"
@@ -62,7 +67,14 @@ export const AdminHeader: React.FC = () => {
6267
<FiLoader size="16px" color={COLORS.gray700} />
6368
<LabelSmall color={COLORS.gray700}>Progress Tracker</LabelSmall>
6469
</Flex>
65-
<Flex align="center" gap="8px" cursor="pointer">
70+
<Flex
71+
align="center"
72+
gap="8px"
73+
cursor="pointer"
74+
onClick={handleSignOut}
75+
_hover={{ opacity: 0.7 }}
76+
transition="opacity 0.2s"
77+
>
6678
<FiLogOut size="16px" color={COLORS.gray700} />
6779
<LabelSmall color={COLORS.gray700}>Sign Out</LabelSmall>
6880
</Flex>

frontend/src/pages/admin/directory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ export default function Directory() {
484484
_hover={{ color: COLORS.veniceBlue }}
485485
onClick={() => router.push(`/admin/users/${user.id}`)}
486486
>
487-
{displayName}
487+
{displayName || user.email}
488488
</Text>
489489
</Table.Cell>
490490
<Table.Cell py={1.5} verticalAlign="middle">

0 commit comments

Comments
 (0)