Skip to content

Commit 32d0a7b

Browse files
Copilotaimenng
andcommitted
Security and code quality fixes: remove passwordHash, GEMINI_API_KEY, unused code, and fix closures
Co-authored-by: aimenng <141473804+aimenng@users.noreply.github.com>
1 parent f09a3e2 commit 32d0a7b

5 files changed

Lines changed: 6 additions & 24 deletions

File tree

authContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
7575

7676
const unreadCount = useMemo(() => notifications.filter((n) => !n.read).length, [notifications]);
7777

78-
const resetAuthState = () => {
78+
const resetAuthState = useCallback(() => {
7979
setCurrentUser(null);
8080
setPartner(null);
8181
setUsers([]);
8282
setAllNotifications([]);
8383
cancelCloudWarmup();
8484
clearFocusStatsCache();
8585
clearPeriodTrackerCache();
86-
};
86+
}, []);
8787

8888
const refreshAuthData = useCallback(async () => {
8989
const token = getAuthToken();
@@ -112,7 +112,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
112112
resetAuthState();
113113
}
114114
}
115-
}, []);
115+
}, [resetAuthState]);
116116

117117
useEffect(() => {
118118
refreshAuthData();

context.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,6 @@ const dedupeRecentDuplicateEvents = (items: AnniversaryEvent[]): AnniversaryEven
167167
return deduped;
168168
};
169169

170-
const chunkItems = <T,>(items: T[], size: number): T[][] => {
171-
if (size <= 0) return [items];
172-
const chunks: T[][] = [];
173-
for (let i = 0; i < items.length; i += size) {
174-
chunks.push(items.slice(i, i + size));
175-
}
176-
return chunks;
177-
};
178-
179170
const estimatePayloadBytes = (payload: unknown): number => {
180171
try {
181172
return new Blob([JSON.stringify(payload)]).size;
@@ -686,8 +677,3 @@ export const calculateDateDiff = (targetDate: string): number => {
686677

687678

688679

689-
690-
691-
692-
693-

types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export enum View {
1212
export interface User {
1313
id: string;
1414
email: string;
15-
passwordHash?: string; // Never store plain password in frontend
15+
// NOTE: passwordHash is intentionally excluded from frontend types — it only exists on the backend model.
1616
invitationCode: string; // User's own unique invite code
1717
boundInvitationCode?: string; // Invite code from another account that user has bound
1818
emailVerified?: boolean;

utils/aiService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// AI Service for image analysis
2+
import { getNow } from './timeService';
3+
24
export interface AIAnalysisResult {
35
location?: string;
46
date?: string;
@@ -95,8 +97,6 @@ export async function analyzeImage(imageBase64: string): Promise<AIAnalysisResul
9597
}
9698
}
9799

98-
import { getNow } from './timeService';
99-
100100
/**
101101
* Mock analysis for testing (when no API key)
102102
* Accepts an optional fileDate to use instead of today's date

vite.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export default defineConfig(({ mode }) => {
1616
},
1717
},
1818
plugins: [react()],
19-
define: {
20-
'process.env.API_KEY': JSON.stringify(env.GEMINI_API_KEY),
21-
'process.env.GEMINI_API_KEY': JSON.stringify(env.GEMINI_API_KEY)
22-
},
2319
resolve: {
2420
alias: {
2521
'@': path.resolve(__dirname, '.'),

0 commit comments

Comments
 (0)