IdentityServer icon indicating copy to clipboard operation
IdentityServer copied to clipboard

use static equals method to avoid exception

Open testfirstcoder opened this issue 1 year ago • 2 comments

user.Password could be null.

testfirstcoder avatar Aug 16 '24 13:08 testfirstcoder

Is it actually possible to create a TestUser instance without a password, or to submit the QuickStart ui's login page without entering a password? If so, maybe we should prevent that. Ultimately the TestUserStore isn't meant for production, so we should just make the developer experience as good as possible.

josephdecock avatar Aug 17 '24 00:08 josephdecock

The previous line checks explicit the possible null value for user password.

if (string.IsNullOrWhiteSpace(user.Password)

Right. The type is for testing purpose only.

Nevertheless we could use Object.Equals or String.Equals methods to make a safer comparision and avoid a possible System.NullReferenceException.

testfirstcoder avatar Aug 19 '24 07:08 testfirstcoder

Okay, I had some thought of possibly looking at nullability annotations to make this impossible, but on second thought I'm just going to go ahead and merge it and not worry about the annotations. Thanks @testfirstcoder!

josephdecock avatar Dec 05 '24 02:12 josephdecock