Identity Event Handlers

All event handlers examples are provided in a pair - implementation/registration as follows:

  • implementation - requires from you to make a class that must implement corresponding contract
  • registration - requires from you to register the handler into the DI container in your application startup

Login

public class LoginEventHandler : ILoginEventHandler
{
    public async Task HandleAsync(LoginEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
    }
}
services.SubscribeToLoginEvent<LoginEventHandler>();

External login

public class ExternalLoginEventHandler : IExternalLoginEventHandler
{
    public async Task HandleAsync(ExternalLoginEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
    }
}
services.SubscribeToExternalLoginEvent<ExternalLoginEventHandler>();

Register

public class RegisterEventHandler : IRegisterEventHandler
{
    public async Task HandleAsync(RegisterEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
        // args.EmailConfirmationLink
    }
}
services.SubscribeToRegisterEvent<RegisterEventHandler>();

External register

public class ExternalRegisterEventHandler : IExternalRegisterEventHandler
{
    public async Task HandleAsync(ExternalRegisterEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
    }
}
services.SubscribeToExternalRegisterEvent<ExternalRegisterEventHandler>();

Forgot password

public class ForgotPasswordEventHandler : IForgotPasswordEventHandler
{
    public async Task HandleAsync(ForgotPasswordEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
        // args.ResetPasswordLink
    }
}
services.SubscribeToForgotPasswordEvent<ForgotPasswordEventtHandler>();

Reset password

public class ResetPasswordEventHandler : IResetPasswordEventHandler
{
    public async Task HandleAsync(ResetPasswordEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
    }
}
services.SubscribeToResetPasswordEvent<ResetPasswordEventHandler>();

Confirmed email

public class ConfirmedEmailEventHandler : IConfirmedEmailEventHandler
{
    public async Task HandleAsync(ConfirmedEmailEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
    }
}
services.SubscribeToConfirmedEmailEvent<ConfirmedEmailEventHandler>();

Request change email

public class RequestChangeEmailEventHandler : IRequestChangeEmailEventHandler
{
    public async Task HandleAsync(RequestChangeEmailEventArgs args)
    {
        // Your code comes here
        // Event arguments are as follows:
        // args.UserId
        // args.HttpContext
        // args.EmailConfirmationLink
        // args.NewEmail
    }
}
services.SubscribeToRequestChangeEmailEvent<RequestChangeEmailEventHandler>();