Skip to main content
All docs
V24.2
.NET 8.0+
  • The page you are viewing does not exist in the .NET Framework 4.6.2+ platform documentation. This link will take you to the parent topic of the current section.

AuthenticationStandardEvents.OnFindUser Property

Specifies custom logic used to find a user object.

Namespace: DevExpress.ExpressApp.Security

Assembly: DevExpress.ExpressApp.Security.v24.2.dll

NuGet Package: DevExpress.ExpressApp.Security

Declaration

public Action<FindUserContext> OnFindUser { get; set; }

Property Value

Type Description
Action<DevExpress.ExpressApp.Security.FindUserContext>

A delegate method that implements custom logic.

Remarks

Handle this event to implement custom logic used to find a user object. In the event handler, if the user object is found, assign this object to the context.User property. After that, the XAF authentication system carries out all checks required for standard password-based authentication.

Note

In contrast to the OnFindUser event, the OnAuthenticate event completely overrides the authentication logic and requires you to implement all checks manually. Use this event for deeper customization of authentication behavior (for example, to implement authentication based on custom logon parameters).

The following code snippet demonstrates how to use the OnFindUser event:

File: MySolution.Blazor.Server\Startup.cs, MySolution.Win\Startup.cs, MySolution.WebApi\Startup.cs

services.AddXaf(Configuration, builder => {
    // ...
    builder.Security
        .AddPasswordAuthentication(options => {
            options.IsSupportChangePassword = true;
            options.Events.OnFindUser += context => { 
                context.User = context.ObjectSpace.FirstOrDefault<ApplicationUser>(
                    x => x.UserName == context.LogonParameters.UserName
                ); 
            };
        });
        // ...
});
See Also