gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 14:38:27 25 4
gpt4 key购买 nike

我使用声明进行身份验证并基于此文档 auth user我可以使用 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);
}

最佳答案

关于c# - 如何知道使用 Sitefinity OwinContext 登录失败的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59027498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com