[WIP] Remove passwordHash from frontend User type for security - #11
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… unused code, and fix closures Co-authored-by: aimenng <141473804+aimenng@users.noreply.github.com>
|
Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information |
aimenng
marked this pull request as ready for review
February 12, 2026 14:22
Copilot stopped work on behalf of
aimenng due to an error
February 12, 2026 14:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security and Code Quality Fixes Plan
passwordHashfield from User interface in types.tschunkItemsfunction from context.tsxresetAuthStatein useCallbackOriginal prompt
Overview
This PR addresses security vulnerabilities, code quality issues, and optimization opportunities discovered during a comprehensive code audit. All changes are carefully scoped to avoid breaking existing functionality.
Changes Required
1. 🔒 Security: Remove
passwordHashfrom frontend User type (types.ts)The
Userinterface intypes.tsline 15 currently exposespasswordHashas an optional field. Even though the backend likely strips it before sending, having it in the frontend type is a security anti-pattern and signals that server-only data might leak.Fix: Remove the
passwordHashfield from the frontendUserinterface. Add a comment noting that the full user model lives on the backend.Current code (line 12-24):
Should become:
2. 🔒 Security: Remove GEMINI_API_KEY injection from Vite config (
vite.config.ts)vite.config.tslines 19-22 currently injectGEMINI_API_KEYinto the frontend JavaScript bundle viadefine. This means anyone can extract the API key from the browser devtools or the built JS files.Current code (lines 19-22):
Fix: Remove the entire
defineblock. The AI service (utils/aiService.ts) already uses its own API key mechanism vialocalStorage(for the Doubao API), andGEMINI_API_KEYis not actually referenced anywhere in the frontend source code viaprocess.env.GEMINI_API_KEYorprocess.env.API_KEY. Search the codebase to confirm — if there are references, they should be moved to use the backend proxy pattern instead, but from my audit they don't exist.The resulting
vite.config.tsshould be:3. 🔧 Code Quality: Fix
chunkItemsdead code incontext.tsxThe function
chunkItems(lines 170-177 incontext.tsx) is defined but never used anywhere in the file or the project. The file usesbuildAdaptiveMemoryChunksinstead.Fix: Remove the
chunkItemsfunction entirely fromcontext.tsx.Remove these lines:
4. 🔧 Code Quality: Fix stale closure in
authContext.tsxIn
authContext.tsx,refreshAuthData(line 88) is wrapped withuseCallback(…, [])but internally callsresetAuthState()which is a plain function referencing state setters. While the React setState functions themselves are stable, theresetAuthStatefunction should be wrapped inuseCallbackto make the dependency intent explicit and avoid future refactoring bugs.Fix: Wrap
resetAuthStateinuseCallback:Change:
To:
Then add
resetAuthStateto the dependency array ofrefreshAuthData:5. 🔧 Code Quality: Remove trailing blank lines in
context.tsxcontext.tsxhas 7 trailing blank lines (lines 687-694) at the e...This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.