-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-identityIncludes: Identity and providersIncludes: Identity and providersbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The sole purpose of IPasswordValidator is to validate passwords.
The contract allows null password
Task ValidateAsync(UserManager manager, TUser user, string? password);
The implementation of PasswordValidator handle null password correctly:
| if (string.IsNullOrWhiteSpace(password) || password.Length < options.RequiredLength) |
So why does it throw when the password is null ?
aspnetcore/src/Identity/Extensions.Core/src/PasswordValidator.cs
Lines 40 to 42 in 3f1acb5
| public virtual Task<IdentityResult> ValidateAsync(UserManager<TUser> manager, TUser user, string? password) | |
| { | |
| ArgumentNullThrowHelper.ThrowIfNull(password); |
Expected Behavior
Not throw an ArgumentNullException when the password is null, because the contract setup by the IPasswordValidator.ValidateAsync says it is allowed.
Steps To Reproduce
The following test should pass instead of failing with ArgumentNullException
[Fact]
public async Task ValidateDoesNotThrowsWithNullPasswordTest()
{
// Setup
var validator = new PasswordValidator<PocoUser>();
// Act
var result = await validator.ValidateAsync(default!, default!, null);
// Assert
Assert.False(result.Succeeded);
}Exceptions (if any)
No response
.NET Version
8.0.400
Anything else?
No response
kjkrum
Metadata
Metadata
Assignees
Labels
area-identityIncludes: Identity and providersIncludes: Identity and providersbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.