fix: Add SSR guards to tokenStorage setters and clear method#6
Merged
gin-melodic merged 2 commits intofeature/fature-pbfrom Feb 13, 2026
Merged
fix: Add SSR guards to tokenStorage setters and clear method#6gin-melodic merged 2 commits intofeature/fature-pbfrom
gin-melodic merged 2 commits intofeature/fature-pbfrom
Conversation
11 tasks
Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Refactor frontend updates based on review feedback
fix: Add SSR guards to tokenStorage setters and clear method
Feb 13, 2026
gin-melodic
added a commit
that referenced
this pull request
Feb 14, 2026
* feat: add protobuf support and update auth flow - Add @bufbuild/protobuf, protobufjs, decimal.js, long, and ts-proto dependencies for protobuf functionality - Add @types/decimal.js as dev dependency - Introduce 'proto' script in package.json for proto generation - Replace direct API calls with useRegister hook in register page - Update useLogin hook usage in login page component - Modify login mutation parameters to use correct field names - Update mock user login to use UserLevelType enum values - Remove manual loading state in favor of mutation pending state - Adjust routing after registration to dashboard * feat(accounts): use translationKey for account type labels - Replace hardcoded label.toLowerCase() with translationKey property - Update ACCOUNT_TYPES definition to include translationKey field - Modify Accounts.tsx, AddAccountModal.tsx, and EditAccountModal.tsx to use translationKey instead of label for i18n consistency fix(auth): enhance session key validation and token refresh logic - Add session key validation in GlobalContext to ensure ALE-encrypted endpoints have required session key - Implement fallback mechanism for token refresh when another tab completes the refresh process - Update getProfile call to use secureAuthService with proper user mapping from protobuf response refactor(2fa): improve 2FA QR code handling - Update UserProfile component to safely access data.secret properties - Use optional chaining and default values for QR URL and secret refactor(network): optimize imports in GlobalContext - Remove unused apiRequest and API_BASE_PATH imports - Import secureAuthService for encrypted API calls * feat(settings): add confirmation flow for base currency updates - Implement two-step confirmation process for changing base currency - Add visual feedback during currency selection with confirmation states - Integrate secureAuthService to update user profile with new main currency - Add loading states and proper error handling for currency updates - Include auto-cancel functionality for confirmation after 3 seconds fix(accounts): replace hardcoded strings with internationalized messages - Add translation keys for account creation, update, and deletion messages - Support multiple languages (en, ja, zh-CN, zh-TW) for account operations - Update success and error toast notifications to use translated content - Remove hardcoded Chinese strings in favor of i18n implementation refactor(proto): update UserInput interface with mainCurrency field - Add optional mainCurrency property to UserInput interface - Update protobuf serialization/deserialization logic to handle mainCurrency - Modify default values and message processing for the new field - Ensure backward compatibility with existing user profiles refactor(auth): add updateProfile method to secureAuthService - Export UserInput type for consistent typing across services - Implement updateProfile endpoint using secureRequest pattern - Add proper request/response type definitions for profile updates - Maintain existing authentication flow while adding update capability chore(accounts): improve mutation hooks with proper translations - Add i18n support to account CRUD operation hooks - Update toast notifications to use localized messages - Fix type annotation for protoInput in update mutation - Maintain consistent error handling patterns across mutations refactor(websocket): change error logging level from error to warning - Update WebSocket error logging to use console.warn instead of console.error - Maintain same debugging information while reducing log severity - Keep connection status tracking consistent with new warning approach * feat(auth): integrate global context for user registration flow - Import and utilize GlobalContext in the registration page to manage user state - Update global context with user data upon successful registration - Ensure seamless transition from registration to dashboard with proper authentication state fix(accounts): disable balance input for equity accounts - Extend the condition to disable balance input field for ACCOUNT_TYPE_EQUITY - Prevent users from modifying balance values for expense, income, and equity account types chore(deps): update package-lock.json peer dependency declarations - Add peer property to multiple dependencies in package-lock.json - Ensure proper peer dependency tracking for react, eslint, typescript and other packages - Maintain consistency in dependency management across the project * feat: enhance user feedback and error handling in registration and login flows * fix: lint problems. * Update src/context/GlobalContext.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat(tests): update TestComponent to reflect user login state * Update src/components/layout/Sidebar.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/components/features/settings/CurrencySettings.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/components/features/Transactions.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: Add SSR guards to tokenStorage setters and clear method (#6) * Initial plan * fix: add window guard to tokenStorage setters and clear method Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * Fix nanos overflow in MoneyHelper.toProto() (#7) * Initial plan * fix: normalize nanos overflow in MoneyHelper.toProto() Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: use while loop for more robust nanos normalization Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: simplify nanos normalization logic Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: use Decimal comparison methods for cleaner code Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: use exact equality checks for nanos normalization Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: optimize nanos normalization and clean up tests Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * refactor: use defensive >= and <= checks for nanos normalization Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * test: add assertions to verify nanos always within valid range Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gin-melodic <4485145+gin-melodic@users.noreply.github.com> * fix: fix import sentence to avoid unnecessary runtime imports and potential circular deps. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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.
The
tokenStorageobject had inconsistent SSR safety—getters checkedtypeof window !== 'undefined'but setters andclear()calledlocalStorageunconditionally, causing errors in server-side contexts.Changes
Added window guards to all mutation methods:
setToken(),setRefreshToken(),setSessionKey()now no-op whenwindowis undefinedclear()now no-ops whenwindowis undefinedAll
tokenStoragemethods now handle SSR contexts safely.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.