-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-identityIncludes: Identity and providersIncludes: Identity and providers
Description
Background and Motivation
UserOptions.AllowedUserNameCharacters
is marked as not allowing null
to be assigned to it but the code consuming this property treats a null or empty as all characters being allowed in the username.
else if (!string.IsNullOrEmpty(manager.Options.User.AllowedUserNameCharacters) && |
Proposed API
namespace Microsoft.AspNetCore.Identity;
public class UserOptions
{
+ public string? AllowedUserNameCharacters { get; set; }
- public string AllowedUserNameCharacters { get; set; }
}
Usage Examples
services.Configure<IdentityOptions>(options =>
{
// Allow all characters in usernames
options.User.AllowedUserNameCharacters = null;
});
Alternative Designs
null
can still be disallowed and an empty string should be used to denote that all characters are allowed in usernames.
Risks
There should be no risks, the property will still retain its same default set of characters it will just not cause nullable reference types warnings when null
is set to it.
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-identityIncludes: Identity and providersIncludes: Identity and providers