Skip to content

Commit

Permalink
fix NamedUserCredential (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
iatsuta authored Oct 20, 2024
1 parent aa365ff commit e87a60d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ public abstract record UserCredential

public record NamedUserCredential(string Name) : UserCredential
{
public override bool IsMatch(User user) => user.Name == this.Name;
public override bool IsMatch(User user) => this.IsMatch(user.Name);

public override int GetHashCode() => this.Name.ToLower().GetHashCode();

public virtual bool Equals(NamedUserCredential? other) => other is not null && this.IsMatch(other.Name);

public override string ToString() => this.Name;

private bool IsMatch(string name) => string.Equals(name, this.Name, StringComparison.OrdinalIgnoreCase);
}

public record IdentUserCredential(Guid Id) : UserCredential
Expand Down

0 comments on commit e87a60d

Please sign in to comment.