frontend improvements & bug fixes - #356
Merged
Merged
Conversation
…ure-improvements # Conflicts: # backend/src/main/java/com/swipelab/auth/external/ExternalAuthController.java
SagiEv
marked this pull request as ready for review
August 9, 2026 21:26
edenbar23
approved these changes
Aug 10, 2026
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.
Walkthrough: Frontend Codebase Improvements & Maintenance Mode
This document summarizes all the structural and architectural changes implemented in the frontend application, along with the backend authentication adjustments to accommodate cookie-based web sessions and the newly requested Maintenance Mode.
Structural Improvements
frontend/components/directory and merged its UI components (e.g.,collapsible.tsx,themed-view.tsx) strictly intofrontend/app/components/. We now have a single source of truth for UI components.expo-routerwas completely uninstalled and removed frompackage.json, cutting down unnecessary bundle weight since@react-navigation/nativeis strictly handling all navigation.tsconfig.jsonwas updated to support the@/*alias mapping to./app/*.../../api/apiFetch) were refactored to use the cleaner, module-based@/aliasing.Design System Integration
app/theme/. This abstracts colors, typography, spacing, and border radii.LoginScreento strip out all magic hex colors (like#4B7BE5and#2E8B57), replacing them with semantic equivalents liketheme.colors.primaryandtheme.colors.secondary.Security & API Hardening
Cookie-Based Web Authentication:
AuthController.javaandExternalAuthController.javato setHttpOnlysession cookies (accessTokenandrefreshToken) for browser protection against XSS.SecurityConfigwas also updated to explicitlyallowCredentials(true).localStoragetoken caching entirely and instructsapiFetch.tsto include cookies on all network requests natively. On Mobile, it delegates storage back toexpo-secure-store.authStoreandapiFetchhave been removed in the process.Global Error Handling:
<GlobalErrorBoundary>wrapper around the entire app to catch unexpected React rendering failures gracefully.react-native-toast-messagefor global, visual Toast notifications during standard API failures (4xx codes) instead of failing silently.Maintenance Mode Implementation
apiFetch.tslogic now intercepts any5xxinternal server error responses and immediately dispatches a global state flagisMaintenanceModeinappStateStore.ts.App.tsxconditionally halts the standardRootNavigatorpresentation and renders a full-screen MaintenanceScreen.useHealthCheck.ts, automatically polls the/healthendpoint every 10 seconds while the app is in maintenance mode. Once it returns an HTTP200 OK, the app autonomously resumes standard operation.Tip
The placeholder GIF for the maintenance screen is currently located at
frontend/assets/images/maintenance.gif. Please replace this file with the actual animated GIF you intended to use!Handled Some Console Warnings
Those warnings are specific to React Native Web's rendering in the DOM:
<form>tags. By default, React Native<View>components render as<div>s, which triggers this warning in Chrome. I fixed this by wrapping the inputs in a<View accessibilityRole="form">, which instructs React Native Web to render an actual<form>tag.aria-hidden="true", but the button still technically had focus in the DOM. Browsers flag this as an accessibility violation. I addedKeyboard.dismiss()and a directdocument.activeElement.blur()trigger right when you press login so the button safely releases focus before the screen transition.Both warnings should now be resolved!
Logout error fix
The 401 Unauthorized error during logout was happening because of a combination of two things:
/api/v1/auth/logoutwas accidentally left out of thepermitAll()block inSecurityConfig.java. Spring Security was intercepting the logout request and demanding a valid access token first, throwing the 401 before the request even reached theAuthController!authStore.ts, the code was clearing the token from local storage before making the API call to logout. It also usedcredentials: "omit", which meant the web cookies weren't sent to the backend anyway.I've updated
SecurityConfig.javatopermitAllthe logout route (since we just want to invalidate the refresh token in the payload/cookie). I also updatedauthStore.tsto retrieve therefreshTokenbefore clearing the local state, and changed it tocredentials: "include"so the cookies are successfully sent and cleared by the backend.Task Progression & Button State Fixes
I have successfully implemented the changes outlined in the implementation plan to ensure your users' task progression accurately updates and the interface reacts correctly to their progress.
What was Changed
Immediate Cache Invalidation (
SwipeScreen.tsx):When a user successfully submits a classification (swiping an image), the frontend now explicitly clears the cache for their task lists and global statistics. This forces the app to immediately fetch the new progress (
imagesClassified) behind the scenes. Your progress bars in Quick Start, Task Details, and My Collection will now update instantly without needing to wait 5 minutes for the cache to go stale!Dynamic Task Details Button (
TaskDetailsScreen.tsx):The big blue button at the bottom of the Task Details screen now acts intelligently based on the user's progress:
Verification
Secure Password Changes for External Users
I have successfully restricted all password management functionality so that it is strictly available only for
LOCALusers, completely preventing Google Auth or STARdbi users from changing or resetting passwords.What was Changed
1. Created the Missing Backend Endpoint
The frontend's "Change Password" button was silently failing because the
/api/v1/auth/password/changebackend API didn't actually exist! I created the endpoint inAuthController.javaand implemented its logic inAuthenticationService.javato securely update the user's password.2. Backend Security Enforcement
LOCAL, it instantly throws a security exception./password/forgotlogic has been patched. When an email is submitted, it now checks if the matched user account isLOCAL. If the user is authenticated via Google or STARdbi, it gracefully returns success to prevent email enumeration, but deliberately skips sending a reset token.3. Frontend UI Updates
providertype securely from the backend to the frontend within the user's profile data (UserProfileResponse.java).ProfileScreen.tsx) to conditionally render the "Change Password" button. If the user is logged in via Google Auth or STARdbi, the button is entirely hidden from the UI to avoid confusion.Verification