Skip to content

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

Open
@Bouke

Description

@Bouke

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions