Intercept first Authentication Request

I’ve configured the authentication in this way

var authFeature = new AuthFeature(
() => new MyAuthUserSession(),
new AspNetWindowsAuthProvider(this) { AllowAllWindowsAuthUsers = false }
authFeature.AuthEvents.Add(new MyAuthEvents());

and so the MyAuthEvents class looks like

public class MyAuthEvents : IAuthEvents
public void OnAuthenticated(IRequest httpReq, IAuthSession session, IServiceBase authService, IAuthTokens tokens, Dictionary<string, string> authInfo)
// …


I saw that the OnAuthenticated method is called on every HTTP Request and not only on the first attempt to authenticate (I suppose because the AspNetWindowsAuthProviders implements IAuthWithRequest).

For every new session, how can I intercept the first authentication request ?


You’d normally use OnRegistered() event on Session or IAuthEvents which would only get called when the User was first created. Any Authentication request after the user is created only calls OnAuthenticated()