private void SetInputsInModeMini() { if (IsPostBack) { return; } SocialHelper.RemoveSocialProfileFromSessionIfNeeded(); var socialUserModel = SocialHelper.GetSocialProfileFormSession() != null?SocialHelper.GetSocialProfileFormSession().UserModel : SocialHelper.BindUserModel(); if (socialUserModel != null) { if (socialUserModel.Email.HasText()) { try { if (SocialHelper.CanAuthenticateAsync()) { SocialHelper.SetSocialProfileToSession(SocialHelper.CreateSocialProfileIfNeeded()); divEmail.Visible = false; divConfirmEmail.Visible = false; divPassword.Visible = false; divConfirmPassword.Visible = false; divFirstName.Visible = socialUserModel.FirstName.HasNoText(); divLastName.Visible = socialUserModel.LastName.HasNoText(); if (!(inputFirstName.Visible || inputLastName.Visible)) { divMiddleName.Visible = false; } } else { divSummaryError.Visible = true; ltlMessage.Text = "Cannot validate email " + socialUserModel.Email + ". Please complete registration manually. Possible reasons: <br />1) access to email address is not allowed by user<br />2) email from social network profile is not equal to email obtained with given access token."; } } catch (Exception ex) { divSummaryError.Visible = true; ltlMessage.Text = ex.Message; } } inputFirstName.Value = socialUserModel.FirstName; inputMiddleName.Value = socialUserModel.MiddleName; inputLastName.Value = socialUserModel.LastName; if (socialUserModel.AvatarUrl.HasText()) { divSocImage.Visible = true; imageAvatar.ImageUrl = socialUserModel.AvatarUrl; } } }
private void AuthenticateThroughSocialProvider() { try { var socialAuthenticationModel = SocialHelper.BindAuthenticationModel(); if (SocialHelper.CanAuthenticateAsync()) { var user = Membership.GetUser(socialAuthenticationModel.UserName); if (user != null) { var redirectionUrl = RootURL + "createflyer.aspx"; if (Request["returnurl"].HasText()) { redirectionUrl = new Uri(RootURL.ToUri(), Request["returnurl"]).ToString(); } HandleSocialAuthenticationResponse(socialAuthenticationModel, true, false, redirectionUrl, null); } else { HandleSocialAuthenticationResponse(socialAuthenticationModel, false, true, null, null); } } else { HandleSocialAuthenticationResponse(socialAuthenticationModel, false, true, null, null); } } catch (ThreadAbortException) { } catch (Exception ex) { var message = "Unable to verify your social account. Please try relogin to social network or continue registration manually. Error: " + ex.Message; HandleSocialAuthenticationResponse(null, false, false, null, message); } }