简体   繁体   中英

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

I use claims to authenticate and based on this documentation auth user I can use OwinContext to sign in. However, unlike SecurityManager.Authenticate OwinContext does not return reason of failed sign in.

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);

I need to know the reason of failed sign in. Something like UserLoggingReason in SecurityManager.Authenticate so I can handle the result accordingly.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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