Skip to content

Better and faster login page#9

Merged
MichielDean merged 7 commits into
mainfrom
betterLogin
Jun 1, 2025
Merged

Better and faster login page#9
MichielDean merged 7 commits into
mainfrom
betterLogin

Conversation

@MichielDean
Copy link
Copy Markdown
Owner

@MichielDean MichielDean commented Jun 1, 2025

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 the login function 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 the dev script to include the --turbopack flag for faster development builds.

Copilot AI review requested due to automatic review settings June 1, 2025 02:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/pages/login.tsx Outdated
Comment thread src/pages/index.tsx Outdated
Comment thread src/pages/login.tsx Fixed
Comment thread src/pages/login.tsx Fixed
MichielDean and others added 3 commits May 31, 2025 20:48
…scripting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@MichielDean MichielDean requested a review from Copilot June 1, 2025 02:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Comment thread src/pages/index.tsx Outdated
Comment thread src/pages/login.tsx Outdated
@MichielDean MichielDean requested a review from Copilot June 1, 2025 02:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

@MichielDean MichielDean enabled auto-merge (squash) June 1, 2025 02:56
@MichielDean MichielDean merged commit cac1866 into main Jun 1, 2025
4 checks passed
@MichielDean MichielDean deleted the betterLogin branch June 1, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants