Skip to content

Handle missing connection db records for verified auth0 sessions and improve cache handling#950

Open
roborourke wants to merge 3 commits intoauth0:5.xfrom
roborourke:patch-1
Open

Handle missing connection db records for verified auth0 sessions and improve cache handling#950
roborourke wants to merge 3 commits intoauth0:5.xfrom
roborourke:patch-1

Conversation

@roborourke
Copy link
Contributor

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Describe the purpose of this PR along with any background information and the impacts of the proposed change. For the benefit of the community, please do not assume prior context.

Provide details that support your chosen implementation, including: breaking changes, alternatives considered, changes to the API, etc.

If the UI is being changed, please provide screenshots.

This aims to fix an edge case where auth0 "resumes" a session but no account record has been created in the db so it keeps logging users out on every page request. This can happen when registering a new auth0 account for an existing WP user with a matching email address.

There are some errors in the caching here too that I needed to fix, like putting the expiry in the group parameter.

Flushing the entire cache when deleting a user is unnecessary and can be very damaging to performance on a busy site so I updated that as well, including deleting the transient.

It would be good to look into only using transients, or only wp_cache_* functions rather than combining them as it's not necessary and adding double the number of requests needed for sites with a separate cache server, which can degrade performance rather than improve it.

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

  • This change adds test coverage for new/changed/fixed functionality

  • Before the fix...

  • Create a site with an existing WP user, administrator role

  • Configure and Enable auth0

  • Login again with the user and see that no wp_auth0_accounts record is created

  • Browsing to the front end results in being logged out, after several redirects including to auth0's resume endpoint

  • With the fix...

  • On the next page request to the front end, see that the redirects stop, and authentication is preserved, and the wp_auth0_accounts record is created

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not the default branch

I think there are some errors in the caching here that this aims to fix, like putting the expiry in the group parameter. 

Mainly I'm seeking to fix an edge case where auth0 can "resume" a session but no account record has been created in the db so it keeps logging users out on every page request.
@roborourke roborourke requested a review from a team as a code owner March 19, 2026 11:42
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.

1 participant