Open Closed

Tring to get ProcessSignInContext event from AuthServer #8850


User avatar
0
sghorakavi@cpat.com created
  • ABP Framework version: 9.0.4
  • UI Type: MVC / Blazor WASM / Blazor Server
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hi, I can get ProcessSignOutContext event fine. But Not getting ProcessSignInContext event in the Authserver. I have a class and registered it using

PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
    serverBuilder.AddEventHandler(SignInControl.Descriptor);
});

public class SignInControl : IOpenIddictServerHandler<ProcessSignInContext>
{
    public static OpenIddictServerHandlerDescriptor Descriptor { get; }
        = OpenIddictServerHandlerDescriptor.CreateBuilder<ProcessSignInContext>()
            .UseSingletonHandler<OpenIddictCreateIdentitySession>()
            .SetOrder(100_000)
            .SetType(OpenIddictServerHandlerType.Custom)
            .Build();
    protected IdentitySessionManager IdentitySessionManager { get; }
    protected IWebClientInfoProvider WebClientInfoProvider { get; }
    protected IOptions<AbpAccountOpenIddictOptions> Options { get; }
    public SignInControl(IdentitySessionManager identitySessionManager, IWebClientInfoProvider webClientInfoProvider, IOptions<AbpAccountOpenIddictOptions> options)
    {
        IdentitySessionManager = identitySessionManager;
        WebClientInfoProvider = webClientInfoProvider;
        Options = options;
    }

    public ValueTask HandleAsync(ProcessSignInContext context)
    {
    //...
    }
    }

1 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    Hello,

    Can you try the following code?

    public sealed class MyPrepareIdentityTokenPrincipal : IOpenIddictServerHandler<OpenIddictServerEvents.ProcessSignInContext>
    {
        public static OpenIddictServerHandlerDescriptor Descriptor { get; }
            = OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ProcessSignInContext>()
                .AddFilter<OpenIddictServerHandlerFilters.RequireIdentityTokenGenerated>()
                .UseSingletonHandler<MyPrepareIdentityTokenPrincipal>()
                .SetOrder(OpenIddictServerHandlers.PrepareIdentityTokenPrincipal.Descriptor.Order + 1)
                .SetType(OpenIddictServerHandlerType.Custom)
                .Build();
    
        public ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }
    
            // ....
    
            return default;
        }
    }
    

    Then add it to the PreConfigureServices method of the module class as follows:

            public override void PreConfigureServices(ServiceConfigurationContext context)
            {
                //  ....
                
    
                PreConfigure<OpenIddictServerBuilder>(builder =>
                {
                    builder.AddEventHandler(MyPrepareIdentityTokenPrincipal.Descriptor);
                });
            }
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08