示例#1
0
        /// <inheritDoc/>
        public virtual LoginFormViewModel Authenticate(LoginFormViewModel input, HttpContextBase context)
        {
            User user;
            UserLoggingReason result = SecurityManager.AuthenticateUser(
                this.MembershipProvider,
                input.UserName,
                input.Password,
                input.RememberMe,
                out user);

            var identity = ClaimsManager.GetCurrentIdentity();

            if (user != null && identity != null && identity.OriginalIdentity is SitefinityIdentity)
            {
                IClaimsPrincipal cp = new ClaimsPrincipal(new[] { new ClaimsIdentity(identity.Claims) });
                var wifCredentials  = new FederatedServiceCredentials(FederatedAuthentication.ServiceConfiguration);
                cp = wifCredentials.ClaimsAuthenticationManager.Authenticate(context.Request.RequestType, cp);
                SitefinityClaimsAuthenticationModule.Current.AuthenticatePrincipalWithCurrentToken(cp, input.RememberMe);
            }

            if (result == UserLoggingReason.Unknown)
            {
                input.IncorrectCredentials = true;
            }
            else
            {
                string redirectUrl;
                if (!this.TryResolveUrlFromUrlReferrer(context, out redirectUrl))
                {
                    redirectUrl = this.GetPageUrl(this.LoginRedirectPageId);
                }

                input.RedirectUrlAfterLogin = redirectUrl;

                if (result != UserLoggingReason.Success)
                {
                    SFClaimsAuthenticationManager.ProcessRejectedUser(context, input.RedirectUrlAfterLogin);
                }
            }

            return(input);
        }