Skip to content

Conversation

@robertsreberski
Copy link
Contributor

@robertsreberski robertsreberski commented Mar 27, 2025

Proposed Changes

  • Change authentication flow to use redirectToLogout instead of logoutUser for Jetpack social logins (Google, Apple, GitHub)
  • Fix error handling in Google auth callback to silently continue when user already exists
  • Simplify Apple authentication by using a local random nonce generation instead of API request
  • Ensure consistent logout handling across all social authentication methods
  • Improve code structure with early returns for logged-in users in authentication flows

@github-actions
Copy link

github-actions bot commented Mar 27, 2025

@matticbot
Copy link
Contributor

matticbot commented Mar 28, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~14 bytes added 📈 [gzipped])

Details
name         parsed_size           gzip_size
entry-login       -133 B  (-0.0%)      +14 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@robertsreberski robertsreberski requested a review from Copilot March 28, 2025 05:34
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 28, 2025
Copy link
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 improves the social authentication flows by updating the logout handling, refining error handling in Google auth callback, and simplifying the authentication nonce generation for Apple logins.

  • Replace logoutUser with redirectToLogout for consistent logout behavior.
  • Modify error handling in Google auth callback to silently ignore user existence errors.
  • Simplify Apple authentication by using a locally generated nonce.

notice: {
status: 'is-warning',
text: 'Could not complete Google login. Please try again.',
// Silently fail: user already exists
Copy link

Copilot AI Mar 28, 2025

Choose a reason for hiding this comment

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

The catch block in jetpackGoogleAuthCallback silently swallows all errors, which may mask unexpected issues. Consider filtering errors to only ignore the specific 'user already exists' case or log other errors for debugging purposes.

Suggested change
// Silently fail: user already exists
if (createError.message.includes('user already exists')) {
// Silently fail: user already exists
} else {
console.error('Unexpected error during user creation:', createError);
}

Copilot uses AI. Check for mistakes.
@robertsreberski robertsreberski merged commit 30b8af0 into trunk Mar 28, 2025
16 checks passed
@robertsreberski robertsreberski deleted the fix/jetpack-auth-improvements-7 branch March 28, 2025 05:54
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 28, 2025
manzoorwanijk added a commit that referenced this pull request Apr 25, 2025
manzoorwanijk added a commit that referenced this pull request Apr 29, 2025
* Revert "Properly handle redirect_to in fallback login page (#102117)"

This reverts commit 24f8f5e.

* Revert "Jetpack Onboarding: various auth improvements (#102106)"

This reverts commit da747fd.

* Revert "Improve error handling in auth flows (#102027)"

This reverts commit fd52d8c.

* Revert "My Jetpack: redirect logged in users to the connection page (#102644)"

This reverts commit 6a41e3e.

* Revert "Improve log in handling for Google (#102018)"

This reverts commit 30b8af0.

* Revert "Add back logging out (#102015)"

This reverts commit 54afb7e.

* Revert "Fix Apple and GitHub redirects (#102011)"

This reverts commit f39b9e4.

* Revert "Next bunch on auth improvements (#101996)"

This reverts commit 3de680b.

* Revert "Various improvements of direct Jetpack auth (#101988)"

This reverts commit 7a3558a.

* Revert "Improve error redirects (#101865)"

This reverts commit e2c6064.

* Revert "MARTECH-42 Various Jetpack direct auth improvements and fixes (#101859)"

This reverts commit d49fc76.

* Revert "Add direct GitHub auth and callback server-side (#101672)"

This reverts commit bec8c74.

* Revert "Do not run Jetpack social auth endpoints on serverside (#101832)"

This reverts commit 2d915a9.

* Revert "Remove oauth env checks in social auth Jetpack (#101802)"

This reverts commit 0639270.

* Revert "Revert the improvement to the original code (#101801)"

This reverts commit d959108.

* Revert "Fix nonce handling in auth request (#101800)"

This reverts commit 013bd4e.

* Revert "JPMT-31 Apple authentication endpoint for Jetpack (#101658)"

This reverts commit 0c55e09.

* Revert "JPMT-30 Add direct Google auth endpoint for Jetpack (#101588)"

This reverts commit 93dbf58.

* Revert "Support auto trigger of magiclink auth (#101601)"

This reverts commit 2984e31.

* Revert "JPMT-29 Improve Google Auth handling based on testing (#101508)"

This reverts commit 7011770.

* Revert "JPMT-29 Add direct authentication endpoints for social providers (#101427)"

This reverts commit b45e821.
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