Skip to content

Refactor authentication middleware to streamline session management a…#366

Merged
Stivenjs merged 3 commits into
mainfrom
cli
Oct 18, 2025
Merged

Refactor authentication middleware to streamline session management a…#366
Stivenjs merged 3 commits into
mainfrom
cli

Conversation

@Stivenjs
Copy link
Copy Markdown
Contributor

…nd enhance error handling

This commit removes unnecessary production logging from the authentication middleware and simplifies the getSession function by eliminating the forceRefresh parameter. It also introduces a clearAllSessionCache function for better cache management during tests. Additionally, the middleware now consistently retrieves user sessions without redundant logging, improving overall performance and maintainability of the authentication flow.

…nd enhance error handling

This commit removes unnecessary production logging from the authentication middleware and simplifies the getSession function by eliminating the forceRefresh parameter. It also introduces a clearAllSessionCache function for better cache management during tests. Additionally, the middleware now consistently retrieves user sessions without redundant logging, improving overall performance and maintainability of the authentication flow.
…hing

This commit updates the authentication middleware to include the new AuthFetchUserAttributesServer function, allowing for the retrieval of user attributes alongside the current user session. The getSession function is modified to utilize these attributes for improved session management, ensuring that user-specific data such as plan and nickname are accurately reflected. Additionally, tests are updated to validate the integration of user attributes, enhancing the overall reliability and clarity of the authentication process.
…management

This commit introduces a new user authentication cache invalidation feature in the Polar webhook processing logic, ensuring that user data is up-to-date immediately after subscription events. Additionally, a separate cache for user attributes is added with a shorter TTL to improve the efficiency of critical data retrieval. The getSession function is updated to prioritize fetching user attributes from the cache, reducing unnecessary calls to the server. Tests are also updated to reflect these changes, ensuring robust session management and cache handling.
@Stivenjs Stivenjs merged commit 690e9bf into main Oct 18, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant