AuthenticationStandardEvents.OnUserValidated Property
Specifies custom logic used to implement additional validation checks that run after the standard checks succeed.
Namespace: DevExpress.ExpressApp.Security
Assembly: DevExpress.ExpressApp.Security.v24.1.dll
NuGet Package: DevExpress.ExpressApp.Security
Declaration
Property Value
Type | Description |
---|---|
Action<DevExpress.ExpressApp.Security.ValidateUserContext> | A delegate method that implements custom logic. |
Remarks
Use this event to implement additional user validation logic on top of the standard validation checks. The specified validation logic runs after the standard checks succeed. If validation fails, assign an AuthenticationException
to the context.ValidationError
property.
Important
Do not throw an exception directly from the handler method. This can lead to faulty behavior.
File: MySolution.Blazor.Server\Startup.cs, MySolution.Win\Startup.cs, MySolution.WebApi\Startup.cs
The following code snippet demonstrates how to use the OnUserValidated
event:
services.AddXaf(Configuration, builder => {
// ...
builder.Security
.AddPasswordAuthentication(options => {
options.IsSupportChangePassword = true;
options.Events.OnUserValidated += context => {
if(((CustomLogonParameters)context.LogonParameters).CustomData == "FAIL") {
context.ValidationError = new AuthenticationException(context.User.UserName);
}
};
});
// ...
});