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
#Property Value
Type | Description |
---|---|
Action<DevExpress. |
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 On
event, the On
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
);
};
});
// ...
});