Skip to content

Commit f943c5e

Browse files
committed
Feat: FindFirstOrDefault
1 parent 43e84b5 commit f943c5e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/CodeOfChaos.Extensions/ClaimsPrincipalExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ public static IEnumerable<string> FindAllValues(this ClaimsPrincipal principal,
1212
IEnumerable<Claim> claims = principal.FindAll(type);
1313
return claims.Select(c => c.Value);
1414
}
15+
16+
public static Claim? FindFirstOrDefault(this ClaimsPrincipal principal, string type)
17+
=> principal.Claims.FirstOrDefault(claim => claim.Type == type);
1518
}

0 commit comments

Comments
 (0)