diff options
Diffstat (limited to 'src/Utilities/ClaimExtensions.cs')
| -rw-r--r-- | src/Utilities/ClaimExtensions.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Utilities/ClaimExtensions.cs b/src/Utilities/ClaimExtensions.cs new file mode 100644 index 0000000..f8becc2 --- /dev/null +++ b/src/Utilities/ClaimExtensions.cs @@ -0,0 +1,16 @@ +using System.Linq; +using System.Security.Claims; +using System.Security.Principal; + +namespace IOL.Fagprove.Utilities +{ + public static class ClaimExtensions + { + public static string GetClaimValue(this IPrincipal currentPrincipal, string key) + { + var identity = currentPrincipal.Identity as ClaimsIdentity; + var claim = identity?.Claims.FirstOrDefault(c => c.Type == key); + return claim?.Value; + } + } +}
\ No newline at end of file |
