Open Closed

Accessing the ServiceProvider in the IOpenIddictServerHandler class #5964


User avatar
0
ademaygun created
  • ABP Framework version: v7.3.2
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace: No exception
  • Steps to reproduce the issue:

As expressed by the user @mgurer , the methods of the class we implemented from IAbpClaimsPrincipalContributor are not being triggered in the refresh token flow. Therefore, we created a class derived from MyPrepareAccessTokenPrincipal. However, within the HandleAsync, how can we use our repository class?

public ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context)
    {
	    var identity = context.AccessTokenPrincipal?.Identities.FirstOrDefault();
		var userId = identity?.FindUserId();
		if (userId!=null)
		{
		  var user = userRepository.GetAsync(userId); //<-- HOW CAN I INJECT userRepository
		}
		
        return default;
    }

1 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi, you can use dependency injection:

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19