private async Task <IHttpActionResult> ProcessSignInAsync(SignInRequestMessage msg)
        {
            var result = await _validator.ValidateAsync(msg, User as ClaimsPrincipal);

            if (result.IsSignInRequired)
            {
                Logger.Info("Redirecting to login page");
                return(RedirectToLogin(result));
            }
            if (result.IsError)
            {
                Logger.Error(result.Error);
                await _events.RaiseFailureWsFederationEndpointEventAsync(
                    WsFederationEventConstants.Operations.SignIn,
                    result.RelyingParty.Realm,
                    result.Subject,
                    Request.RequestUri.AbsoluteUri,
                    result.Error);

                return(BadRequest(result.Error));
            }

            var responseMessage = await _signInResponseGenerator.GenerateResponseAsync(result);

            await _cookies.AddValueAsync(WsFederationPluginOptions.CookieName, result.ReplyUrl);

            await _events.RaiseSuccessfulWsFederationEndpointEventAsync(
                WsFederationEventConstants.Operations.SignIn,
                result.RelyingParty.Realm,
                result.Subject,
                Request.RequestUri.AbsoluteUri);

            return(new SignInResult(responseMessage));
        }
        private async Task <IHttpActionResult> ProcessSignInAsync(SignInRequestMessage msg)
        {
            var result = await _validator.ValidateAsync(msg, User as ClaimsPrincipal);

            if (result.IsSignInRequired)
            {
                return(RedirectToLogin(result));
            }
            if (result.IsError)
            {
                return(BadRequest(result.Error));
            }

            var responseMessage = await _signInResponseGenerator.GenerateResponseAsync(result);

            await _cookies.AddValueAsync(WsFederationPluginOptions.CookieName, result.ReplyUrl);

            return(new SignInResult(responseMessage));
        }