From 3dccff9c6483b44364d5b8b74045d02c252119ec Mon Sep 17 00:00:00 2001 From: Adrian Ochmann Date: Mon, 15 Feb 2021 15:05:09 +0100 Subject: [PATCH] feat: added role principal extensions --- .../Extensions/RolePrincipalExtensions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Source/Cogworks.Essentials/Extensions/RolePrincipalExtensions.cs diff --git a/Source/Cogworks.Essentials/Extensions/RolePrincipalExtensions.cs b/Source/Cogworks.Essentials/Extensions/RolePrincipalExtensions.cs new file mode 100644 index 0000000..d27ab94 --- /dev/null +++ b/Source/Cogworks.Essentials/Extensions/RolePrincipalExtensions.cs @@ -0,0 +1,13 @@ +using System.Security.Principal; + +namespace Cogworks.Essentials.Extensions +{ + public static class RolePrincipalExtensions + { + public static bool IsUserLoggedIn(this IPrincipal user) + => user.HasValue() && user.Identity.HasValue() && user.Identity.Name.HasValue(); + + public static string GetUser(this IPrincipal user) + => user?.Identity?.Name; + } +}