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);
}
I suggest you have a look at how the Sitefinity widgets, eg the LoginForm does this:
You'll probably be interested in the GetReturnUrl implementation:
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.