Exemple #1
0
        private Boolean IsSocialAuthenticationProvider()
        {
            var result = Request["authenticationProvider"].HasText();

            if (!result)
            {
                result = SocialHelper.IsLinkedInCodeRedirect();

                if (result)
                {
                    var state = SocialHelper.GetLinkedInAuthenticationState();

                    if (state.HasNoText())
                    {
                        Response.Redirect("~/login.aspx", true);
                    }
                    else if (String.Compare(state, Request["state"], false) != 0)
                    {
                        Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Cross Site Request Forgery attempt detected.");
                    }
                }
            }

            return(result);
        }
Exemple #2
0
        private void HandleSocialAuthenticationResponse(SocialAuthenticationModel authenticationModel, Boolean isAuthenticated, Boolean canContinueRegistration, String redirectionUrl, String message)
        {
            if (SocialHelper.IsLinkedInCodeRedirect())
            {
                HandleLinkedInAuthenticationResponse(authenticationModel, isAuthenticated, canContinueRegistration, redirectionUrl, message);
            }
            else
            {
                if (isAuthenticated)
                {
                    FormsAuthentication.SetAuthCookie(authenticationModel.UserName, CreatePersistentCookie());
                }

                var result = new
                {
                    Result = isAuthenticated,
                    CanContinueRegistration = canContinueRegistration,
                    RedirectionUrl          = redirectionUrl,
                    Message = message
                };

                Helper.RespondWithJsonObject(result, Response);
            }
        }
Exemple #3
0
 private Boolean CanAuthenticate()
 {
     return(Request.IsPost() || SocialHelper.IsLinkedInCodeRedirect());
 }