AuthenticationStandardEvents.OnFindUser Property
Specifies custom logic used to find a user object.
Namespace: DevExpress.ExpressApp.Security
Assembly: DevExpress.ExpressApp.Security.v25.1.dll
NuGet Package: DevExpress.ExpressApp.Security
Declaration
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
);
};
});
// ...
});