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_6 (already cloned)
- Base commit: 99885b699d7524e87697f78608e6f2b36c9d8a8e
- Task ID: juspay__hyperswitch-8601
- Version: v1.115.0
TASK DESCRIPTION: Bug: Deleting a user role and again assigning a role to user is not updating its previous role to new role
Role id is not getting updated in the invited user account in case the role is deleted and assigned again to invited user. This is happening due to the lineage context stored in db not updating the role id in case that role id does not exist any more.
Steps to duplicate this edge case:
- Invite a user with any user role
- Accept the invitation and login to invited user account
- Delete the user role from the account who invited the user
- Assign a user role, then try to login to the invited account
- Invited account still operates on the previous user role because of the lineage context getting stored in db
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR fixes an issue where a stale
role_idfrom the cachedlineage_contextwas being used to generate the JWT token during sign-in, even if the actual user role was modified (e.g., role deleted and recreated with a differentrole_idbut same lineage).Previously, we only validated if a user role existed for the lineage (
user_id,tenant_id,org_id,merchant_id,profile_id), but did not verify that therole_idmatched the current assigned role. This led to JWTs being issued with outdatedrole_idvalues.Changes Made
- During sign-in, added a strict match check for in the fetched user role.
Assistant
I'll tackle this bug where deleting and reassigning a user role doesn't properly update the lineage context in the hyperswitch repository. Let me start by exploring the codebase to understand how user roles and lineage context are handled.
First, let me create a plan for this task:
Assistant
Let me search for files related to user roles, lineage context, and sign-in functionality to understand how this is implemented:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me look for files related to user authentication and sign-in functionality:
Assistant
Now let me examine the key files that seem most relevant - the user core module and the user role implementation:
Assistant
Let me search more specifically for the JWT token generation and sign-in flow:
Assistant
Let me look at the JWT service and authentication files specifically:
Assistant
(no content)
Assistant
Let me focus on the user role and lineage context files that I found earlier:
Assistant
(no content)
Assistant
(no content)
Assistant
Now let me examine the types for the LineageContext:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me look more specifically at the user role and authentication implementation to understand the flow better:
Assistant
Let me examine the diesel models to understand the structure better:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.