【发布时间】:2019-06-30 21:44:25
【问题描述】:
我正在尝试使用自定义标签助手验证当前授权是否处于特定角色。我想使用UserManager.IsInRoleAsync(),但是我需要传入一个User 对象。
如何访问当前的授权用户?
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
base.PreProcess(context, output);
bool isInRole = _um.IsInRoleAsync(????, this.Roles); ;
var policy = await AuthorizationPolicy.CombineAsync(_policy, new[] { this });
var authResult = await _eva.AuthenticateAsync(policy, _http.HttpContext);
var authorizeResult = await _eva.AuthorizeAsync(policy, authResult, _http.HttpContext, null);
}
【问题讨论】:
标签: c# authentication asp.net-core asp.net-core-identity