reorg
This commit is contained in:
parent
d000f77098
commit
40e8e08690
3487 changed files with 39 additions and 21 deletions
28
src/Yavsc.Server/Helpers/UserHelpers.cs
Normal file
28
src/Yavsc.Server/Helpers/UserHelpers.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System.Security.Claims;
|
||||
|
||||
namespace Yavsc.Server.Helpers
|
||||
{
|
||||
public static class UserHelpers
|
||||
{
|
||||
public static string GetUserId(this ClaimsPrincipal user)
|
||||
{
|
||||
return user.FindFirstValue("sub");
|
||||
}
|
||||
|
||||
public static string GetUserName(this ClaimsPrincipal user)
|
||||
{
|
||||
return user.FindFirstValue("name");
|
||||
}
|
||||
|
||||
public static bool IsSignedIn(this ClaimsPrincipal user)
|
||||
{
|
||||
return user.Identity.IsAuthenticated;
|
||||
}
|
||||
|
||||
public static bool IsInMsRole(this ClaimsPrincipal user, string roleName)
|
||||
{
|
||||
return user.HasClaim("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", roleName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue