2023-03-19 17:57:55 +00:00
|
|
|
using System.Security.Claims;
|
2017-02-01 19:53:10 +01:00
|
|
|
|
2025-07-15 19:43:41 +01:00
|
|
|
namespace Yavsc.Server.Helpers
|
2017-02-01 19:53:10 +01:00
|
|
|
{
|
|
|
|
|
public static class UserHelpers
|
|
|
|
|
{
|
2023-03-19 17:57:55 +00:00
|
|
|
public static string GetUserId(this ClaimsPrincipal user)
|
|
|
|
|
{
|
2024-03-04 01:02:19 +00:00
|
|
|
return user.FindFirstValue("sub");
|
2023-03-19 17:57:55 +00:00
|
|
|
}
|
2024-12-03 01:44:58 +00:00
|
|
|
|
2023-03-19 17:57:55 +00:00
|
|
|
public static string GetUserName(this ClaimsPrincipal user)
|
|
|
|
|
{
|
2025-07-10 15:19:28 +01:00
|
|
|
return user.FindFirstValue("name");
|
2023-03-19 17:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsSignedIn(this ClaimsPrincipal user)
|
|
|
|
|
{
|
|
|
|
|
return user.Identity.IsAuthenticated;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 19:53:10 +01:00
|
|
|
}
|
|
|
|
|
}
|