Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TKey should be reference type, or compared against default #43

Open
Bouke opened this issue Oct 13, 2021 · 0 comments
Open

TKey should be reference type, or compared against default #43

Bouke opened this issue Oct 13, 2021 · 0 comments

Comments

@Bouke
Copy link

Bouke commented Oct 13, 2021

Various places in the SignInManager compare the userId against null. This is a problem for value types, for example Guid. I cannot use Guid? in my TUser as it needs to implement IEquatable<TKey>.

public override Guid ConvertIdFromString(string id) => Guid.Parse(id);

This returns Guid.Empty if id == null. However Guid.Empty != null and various places now assume a valid user. I see two possible fixes for this:

  1. Require TKey to be a reference type: null checks can remain as-is.
  2. Replace null checks with default checks: Guid.Empty == default.

Some places where using a value type is a problem:



return await GetVerifiedUserIdAsync().WithCurrentCulture() != null;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant