Files
StoreWeb/Core/MAX.Framework/Security/ICurrentUser.cs
T

40 lines
913 B
C#

using System.Security.Claims;
namespace MAX.Framework.Security;
/// <summary>
/// 当前登录用户访问器:从当前请求的认证票据中读取用户信息。
/// </summary>
public interface ICurrentUser
{
/// <summary>
/// 当前请求是否已认证
/// </summary>
bool IsAuthenticated { get; }
/// <summary>
/// 当前登录账户名(未登录为 null)
/// </summary>
string? UserName { get; }
/// <summary>
/// 当前用户昵称(未登录为 null)
/// </summary>
string? NickName { get; }
/// <summary>
/// 当前用户的全部声明
/// </summary>
IEnumerable<Claim> Claims { get; }
/// <summary>
/// 获取指定类型的声明值
/// </summary>
string? GetClaimValue(string claimType);
/// <summary>
/// 获取指定类型的声明值并转换为目标类型;不存在或转换失败返回默认值
/// </summary>
T? GetClaimValue<T>(string claimType);
}