using NPin.Framework.Upms.Domain.Shared.Consts;
using Volo.Abp.Users;
namespace NPin.Framework.Upms.Domain.Extensions;
public static class CurrentUserExtensions
{
///
/// 获取用户权限代码列表
///
///
///
public static List GetPermissions(this ICurrentUser currentUser)
{
return currentUser.FindClaims(TokenTypeConst.Permission)
.Select(x => x.Value)
.ToList();
}
///
/// 获取用户组织机构ID列表
///
///
///
public static List GetOrganizationIds(this ICurrentUser currentUser)
{
return currentUser.FindClaims(TokenTypeConst.Organizations)
.Select(x => Guid.Parse(x.Value))
.ToList();
}
///
/// 用户是否是通过Refresh进来的
///
///
///
public static bool IsRefreshToken(this ICurrentUser currentUser)
{
var valOrNull = currentUser.FindClaim(TokenTypeConst.Refresh)?.Value;
return valOrNull is not null && bool.Parse(valOrNull);
}
}