Skip to content

Commit 3b34c13

Browse files
authored
Merge pull request #172 from marcominerva/develop
Make Roles optional in ApiKey and Credential classes
2 parents 592339a + 96a8229 commit 3b34c13

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/SimpleAuthentication.Abstractions/ApiKey/ApiKey.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SimpleAuthentication.ApiKey;
66
/// <param name="Value">The API key value</param>
77
/// <param name="UserName">The user name associated with the current key</param>
88
/// <param name="Roles">The list of roles to assign to the user</param>
9-
public record class ApiKey(string Value, string UserName, IEnumerable<string> Roles)
9+
public record class ApiKey(string Value, string UserName, IEnumerable<string>? Roles = null)
1010
{
1111
/// <inheritdoc />
1212
public virtual bool Equals(ApiKey? other)
@@ -25,8 +25,5 @@ public virtual bool Equals(ApiKey? other)
2525
}
2626

2727
/// <inheritdoc />
28-
public override int GetHashCode()
29-
{
30-
return HashCode.Combine(Value, UserName);
31-
}
28+
public override int GetHashCode() => HashCode.Combine(Value, UserName);
3229
}

src/SimpleAuthentication.Abstractions/BasicAuthentication/Credential.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SimpleAuthentication.BasicAuthentication;
66
/// <param name="UserName">The user name</param>
77
/// <param name="Password">The password</param>
88
/// <param name="Roles">The list of roles to assign to the user</param>
9-
public record class Credential(string UserName, string Password, IEnumerable<string> Roles)
9+
public record class Credential(string UserName, string Password, IEnumerable<string>? Roles = null)
1010
{
1111
/// <inheritdoc />
1212
public virtual bool Equals(Credential? other)
@@ -25,8 +25,5 @@ public virtual bool Equals(Credential? other)
2525
}
2626

2727
/// <inheritdoc />
28-
public override int GetHashCode()
29-
{
30-
return HashCode.Combine(UserName, Password);
31-
}
28+
public override int GetHashCode() => HashCode.Combine(UserName, Password);
3229
}

0 commit comments

Comments
 (0)