コード例 #1
0
ファイル: SignUp.aspx.cs プロジェクト: kokosda/Flyers
        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;
                }
            }
        }