You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_1 (already cloned)
- Base commit: 776bde00efce8be35e0c63c1bdc6215921babddf
- Task ID: juspay__hyperswitch-7844
- Version: v1.113.0
TASK DESCRIPTION: Bug: Last used merchant account context
To enhance the user experience, especially during sign-up or when switching between multiple merchant accounts, we can store the last used merchant account context directly in the users table. This allows the system to automatically restore the previously active context when a user logs in or returns to the dashboard, rather than requiring them to manually select a merchant account each time.
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR introduces lineage context caching to enhance login and account-switch flows with better continuity and reduced DB load.
Key Changes
-
During Login:
- Attempt to fetch the last used
LineageContextfrom Redis (LINEAGE_CONTEXT_<user_id>). - If context is found:
- Validate whether a matching user role exists (using both
V1andV2role versions). - If a valid user_role is found → use this lineage context to issue the JWT token.
- If not → fallback to the default user_role-based resolution logic.
- Validate whether a matching user role exists (using both
- If context is not found in cache, fallback to the existing login flow entirely.
- Attempt to fetch the last used
-
During Account Switch:
- After switching org/merchant/profile context and issuing the new JWT token,
the new
LineageContextis saved to Redis (LINEAGE_CONTEXT_<user_id>). - This allows restoring the last used org/merchant/profile on future logins.
- After switching org/merchant/profile context and issuing the new JWT token,
the new
Assistant
I'll implement the last used merchant account context feature for the hyperswitch repository. Let me start by exploring the codebase to understand the current structure and identify where to make changes.
First, I'll look at the key areas related to user authentication, login flow, and lineage context handling.
Assistant
(no content)
Assistant
Let me look at the router/src/lib.rs file which is likely where the main application logic resides:
Assistant
Let me look at the routes directory to find authentication-related code:
Assistant
Let me search for authentication-related routes, particularly login and user management:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.