本文整理汇总了C#中IFubuRequest.Has方法的典型用法代码示例。如果您正苦于以下问题:C# IFubuRequest.Has方法的具体用法?C# IFubuRequest.Has怎么用?C# IFubuRequest.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFubuRequest
的用法示例。
在下文中一共展示了IFubuRequest.Has方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RightsFor
public AuthorizationRight RightsFor(IFubuRequest request)
{
var authToken = request.Get<AuthenticationTokenRequest>();
//Workaround: RightsFor is getting called multiple times because of a Fubu bug
if(request.Has<IAuthenticationToken>()) return AuthorizationRight.Allow;
var token = authToken.authToken;
if(token.IsEmpty())
{
if(_currentSdkUser.IsAuthenticated)
{
_logger.LogDebug("No AuthToken was found in this request but a user is authenticated. Using the current user's credentials.");
return AuthorizationRight.Allow;
}
return AuthorizationRight.Deny;
}
_logger.LogDebug("Authentication token {0} found.", token);
var authenticationToken = _tokenRepository.RetrieveByToken(token);
if (authenticationToken == null)
{
return AuthorizationRight.Deny;
}
_logger.LogDebug("Authentication token {0} found and validated for user {1}.", authenticationToken, authenticationToken);
request.Set(authenticationToken);
_currentSdkUser.SetUser(_principalFactory.CreatePrincipal(authenticationToken.Username));
return AuthorizationRight.Allow;
}