繁体   English   中英

如何知道使用Sitefinity OwinContext登录失败的原因?

[英]How to know the reason of failed sign in using Sitefinity OwinContext?

我使用声明进行身份验证,并且基于此文档, 身份验证用户可以使用OwinContext登录。但是,与SecurityManager.Authenticate不同,OwinContext不会返回登录失败的原因。

var owinContext = SystemManager.CurrentHttpContext.Request.GetOwinContext();
var challengeProperties = ChallengeProperties.ForLocalUser(username, password, provider, isPersistent, errorRedirectUrl);
challengeProperties.RedirectUri = successRedirectUrl;

// this call will trigger redirects to the appropriate Identity Provider
owinContext.Authentication.Challenge(challengeProperties, ClaimsManager.CurrentAuthenticationModule.STSAuthenticationType);

我需要知道登录失败的原因。诸如SecurityManager.Authenticate中的UserLoggingReason之类的东西,以便我可以相应地处理结果。

User user;
UserLoggingReason result = SecurityManager.AuthenticateUser(
    provider,
    username,
    password,
    isPersistent,
    out user);

if (result != UserLoggingReason.Success)
{
    SystemManager.CurrentHttpContext.Response.Redirect(errorRedirectUrl, false);
}
else
{
    SystemManager.CurrentHttpContext.Response.Redirect(successRedirectUrl, false);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM