Better and faster login page#9
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR aims to improve and speed up the login experience by showing the login form immediately and refining redirection logic. Key changes include:
- Updating src/pages/login.tsx to display the login form without waiting for the auth provider’s loading state.
- Refining redirection logic in src/pages/index.tsx with faster router replacement and a short-timer fallback.
- Enhancing auth initialization and background profile loading in src/auth/KeycloakProvider.tsx.
- Enabling turbopack for development in package.json.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/pages/login.tsx | Removed blocking loading UI; now directly renders the login form for better UX. |
| src/pages/index.tsx | Streamlined redirection logic with router.replace and a fallback timer. |
| src/auth/KeycloakProvider.tsx | Added extra initialization options and background profile loading for performance. |
| package.json | Updated the development command to use Next.js turbopack. |
…scripting Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
… into betterLogin
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the authentication and routing experience by optimizing redirects, improving the Keycloak provider initialization, and speeding up development builds.
- Streamlines login page flow with URL sanitization and immediate form display
- Implements fast client-side redirects in the home page without intermediate UI
- Adds fast initialization options and background profile loading in KeycloakProvider
- Updates dev script to use Turbopack for quicker local builds
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/pages/login.tsx | Sanitizes the return URL, shows login form immediately, and handles redirects |
| src/pages/index.tsx | Replaces “Redirecting…” UI with immediate router.replace logic and null render |
| src/auth/KeycloakProvider.tsx | Introduces fast init options, background profile loading, and custom login fn |
| package.json | Adds --turbopack flag to the dev script for faster builds |
Comments suppressed due to low confidence (1)
src/auth/KeycloakProvider.tsx:91
- When using stored tokens, the refresh token also needs to be set (e.g.
initOptions.refreshToken = storedRefreshToken) to ensure Keycloak can refresh the session.
initOptions.token = storedToken;
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes the login and authentication flow by enhancing Keycloak initialization, improving redirect logic, and streamlining development scripts.
- Enhanced URL sanitization and immediate redirection on the login page
- Refactored fast redirects in the home page to eliminate the loading flash
- Improved Keycloak initialization and updated the development script with the turbopack flag
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/pages/login.tsx | Adds URL sanitization for redirectPath and removes the loading UI for authenticated users |
| src/pages/index.tsx | Implements fast redirect logic using router.replace and returns null to prevent flash |
| src/auth/KeycloakProvider.tsx | Enhances Keycloak initialization with fast options and background loading for user profiles |
| package.json | Updates the dev script to include the turbopack flag for faster development builds |
Comments suppressed due to low confidence (1)
src/pages/index.tsx:23
- The cleanup function references an undefined variable 'timer'. Please remove or properly define 'timer' if a timeout is intended.
return () => clearTimeout(timer);
This pull request introduces optimizations to improve the user experience, particularly around authentication and routing. Key changes include faster redirects, streamlined login flow, and enhanced initialization for the Keycloak provider.
Authentication Flow Improvements:
src/auth/KeycloakProvider.tsx: Enhanced Keycloak initialization by adding fast initialization options (flow,responseMode) and ensuring stored tokens are used directly when available. Background loading of the user profile prevents UI blocking during initial authentication. [1] [2]src/auth/KeycloakProvider.tsx: Updated theloginfunction to avoid automatic redirects and ensure explicit calls to Keycloak-hosted login are handled correctly.Routing Optimizations:
src/pages/index.tsx: Implemented fast redirect logic to the login page or dashboard without waiting for the loading state, eliminating the "Redirecting..." UI for a smoother experience.src/pages/login.tsx: Improved the login page by showing the login form immediately during loading, enhancing time-to-paint and user experience. Added immediate redirection for authenticated users.Development Workflow Update:
package.json: Updated thedevscript to include the--turbopackflag for faster development builds.