示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.openIdType = this.GetParameter("HIGW");
            if (!string.IsNullOrEmpty(this.openIdType))
            {
                this.openIdType = this.openIdType.ToLower().Replace("_", ".");
            }
            OpenIdSettingInfo openIdSettings = MemberProcessor.GetOpenIdSettings(this.openIdType);

            if (openIdSettings == null)
            {
                base.Response.Write("登录失败,没有找到对应的插件配置信息。");
            }
            else
            {
                this.parameters = new NameValueCollection
                {
                    this.Page.Request.Form,
                    this.Page.Request.QueryString
                };
                OpenIdNotify openIdNotify = OpenIdNotify.CreateInstance(this.openIdType, this.parameters);
                openIdNotify.Authenticated += this.Notify_Authenticated;
                openIdNotify.Failed        += this.Notify_Failed;
                try
                {
                    openIdNotify.Verify(30000, HiCryptographer.Decrypt(openIdSettings.Settings));
                }
                catch
                {
                    this.Page.Response.Redirect("/");
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Context.Request.IsAuthenticated)
            {
                FormsAuthentication.SignOut();

                HttpCookie authCookie = FormsAuthentication.GetAuthCookie(HiContext.Current.User.Username, true);

                IUserCookie userCookie = HiContext.Current.User.GetUserCookie();

                if (userCookie != null)
                {
                    userCookie.DeleteCookie(authCookie);
                }

                RoleHelper.SignOut(HiContext.Current.User.Username);
            }

            openIdType = Page.Request.QueryString["HIGW"];

            OpenIdSettingsInfo openIdSettings = MemberProcessor.GetOpenIdSettings(openIdType);

            if (openIdSettings == null)
            {
                Response.Write("登录失败,没有找到对应的插件配置信息。");
            }
            else
            {
                NameValueCollection values = new NameValueCollection();

                values.Add(Page.Request.Form);

                values.Add(Page.Request.QueryString);

                parameters = values;

                OpenIdNotify notify = OpenIdNotify.CreateInstance(openIdType, parameters);

                notify.Authenticated += new EventHandler <AuthenticatedEventArgs>(Notify_Authenticated);

                notify.Failed += new EventHandler <FailedEventArgs>(Notify_Failed);

                notify.Verify(0x7530, Cryptographer.Decrypt(openIdSettings.Settings));
            }
        }
示例#3
0
 private void OpenIdEntryInit()
 {
     this.settings = MemberProcessor.GetOpenIdSettings(this.openIdType);
     if (this.settings == null)
     {
         this.ShowMessage("登录失败,没有找到对应的插件配置信息。", false, "/User/Login", 2);
     }
     else
     {
         this.Parameters = new NameValueCollection
         {
             this.Page.Request.Form,
             this.Page.Request.QueryString
         };
         this.notify = OpenIdNotify.CreateInstance(this.openIdType, this.Parameters);
         this.notify.Authenticated += this.Notify_Authenticated;
         this.notify.Failed        += this.Notify_Failed;
         this.notify.Verify(30000, HiCryptographer.Decrypt(this.settings.Settings));
     }
 }
示例#4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (this.Context.Request.IsAuthenticated)
            {
                System.Web.Security.FormsAuthentication.SignOut();
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(HiContext.Current.User.Username, true);
                IUserCookie           userCookie = HiContext.Current.User.GetUserCookie();
                if (userCookie != null)
                {
                    userCookie.DeleteCookie(authCookie);
                }
                RoleHelper.SignOut(HiContext.Current.User.Username);
            }
            this.openIdType = this.Page.Request.QueryString["HIGW"];
            OpenIdSettingsInfo openIdSettings = MemberProcessor.GetOpenIdSettings(this.openIdType);

            if (openIdSettings == null)
            {
                base.Response.Write("登录失败,没有找到对应的插件配置信息。");
                return;
            }
            this.parameters = new System.Collections.Specialized.NameValueCollection
            {
                this.Page.Request.Form,
                this.Page.Request.QueryString
            };
            OpenIdNotify openIdNotify = OpenIdNotify.CreateInstance(this.openIdType, this.parameters);

            openIdNotify.Authenticated += new System.EventHandler <AuthenticatedEventArgs>(this.Notify_Authenticated);
            openIdNotify.Failed        += new System.EventHandler <FailedEventArgs>(this.Notify_Failed);
            try
            {
                openIdNotify.Verify(30000, HiCryptographer.Decrypt(openIdSettings.Settings));
            }
            catch
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
        }
示例#5
0
        protected override void AttachChildControls()
        {
            string a = this.Page.Request["action"].ToNullString().ToLower();

            if (a == "register")
            {
                PageTitle.AddSiteNameTitle("登录");
            }
            else
            {
                PageTitle.AddSiteNameTitle("注册");
            }
            this.hidIsAuth              = (HtmlInputHidden)this.FindControl("hid_IsAuth");
            this.hidAuthMsg             = (HtmlInputHidden)this.FindControl("hid_AuthMsg");
            this.hidOpenIdType          = (HtmlInputHidden)this.FindControl("hid_OpenIdType");
            this.hidOpenId              = (HtmlInputHidden)this.FindControl("hid_OpenId");
            this.hidToken               = (HtmlInputHidden)this.FindControl("hid_Token");
            this.hidRealName            = (HtmlInputHidden)this.FindControl("hid_RealName");
            this.hidUserId              = (HtmlInputHidden)this.FindControl("hid_UserId");
            this.hidEmail               = (HtmlInputHidden)this.FindControl("hid_Email");
            this.hidIsNeedValidateEmail = (HiddenField)this.FindControl("hidIsNeedValidateEmail");
            this.hidIsOpenGeetest       = (HiddenField)this.FindControl("hidIsOpenGeetest");
            this.client              = (HtmlInputHidden)this.FindControl("client");
            this.client.Value        = base.ClientType.ToString().ToLower();
            this.smsenable           = (HiddenField)this.FindControl("smsenable");
            this.emailenable         = (HiddenField)this.FindControl("emailenable");
            this.txtUserName         = (HtmlInputText)this.FindControl("txtUserName");
            this.txtRegisterUserName = (HtmlInputText)this.FindControl("txtRegisterUserName");
            this.forgetPassword      = (HtmlAnchor)this.FindControl("forgetPassword");
            this.divRealName         = (HtmlGenericControl)this.FindControl("divRealName");
            this.divBirthday         = (HtmlGenericControl)this.FindControl("divBirthday");
            this.divSex              = (HtmlGenericControl)this.FindControl("divSex");
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            this.hidIsNeedValidateEmail.Value = (masterSettings.IsNeedValidEmail ? "1" : "0");
            this.hidIsOpenGeetest.Value       = (masterSettings.IsOpenGeetest ? "1" : "0");
            this.labNickName  = (Label)this.FindControl("labNickName");
            this.labNickName1 = (Label)this.FindControl("labNickName1");
            this.labNickName2 = (Label)this.FindControl("labNickName2");
            this.userPicture  = (HtmlImage)this.FindControl("userPicture");
            this.hid_QuickLoginIsForceBindingMobbile       = (HtmlInputHidden)this.FindControl("hid_QuickLoginIsForceBindingMobbile");
            this.hid_QuickLoginIsForceBindingMobbile.Value = (masterSettings.QuickLoginIsForceBindingMobbile ? "true" : "false");
            if (masterSettings.RegistExtendInfo.Contains("RealName"))
            {
                this.divRealName.Visible = true;
            }
            if (masterSettings.RegistExtendInfo.Contains("Sex"))
            {
                this.divSex.Visible = true;
            }
            if (masterSettings.RegistExtendInfo.Contains("Birthday"))
            {
                this.divBirthday.Visible = true;
            }
            if (masterSettings.IsSurportEmail && masterSettings.IsSurportPhone && masterSettings.SMSEnabled && !string.IsNullOrEmpty(masterSettings.SMSSettings))
            {
                this.smsenable.Value   = "true";
                this.emailenable.Value = "true";
                this.txtUserName.Attributes.Add("placeholder", "请输入用户名/邮箱/手机");
                this.txtRegisterUserName.Attributes.Add("placeholder", "邮箱/手机");
                this.forgetPassword.Visible = true;
            }
            else if (!masterSettings.IsSurportEmail && (!masterSettings.IsSurportPhone || !masterSettings.SMSEnabled || string.IsNullOrEmpty(masterSettings.SMSSettings)))
            {
                this.smsenable.Value   = "false";
                this.emailenable.Value = "true";
                this.txtUserName.Attributes.Add("placeholder", "请输入用户名/邮箱");
                this.txtRegisterUserName.Attributes.Add("placeholder", "邮箱");
            }
            else if (masterSettings.IsSurportEmail && (!masterSettings.IsSurportPhone || !masterSettings.SMSEnabled || string.IsNullOrEmpty(masterSettings.SMSSettings)))
            {
                this.smsenable.Value   = "false";
                this.emailenable.Value = "true";
                this.txtUserName.Attributes.Add("placeholder", "请输入用户名/邮箱");
                this.txtRegisterUserName.Attributes.Add("placeholder", "邮箱");
            }
            else if (!masterSettings.IsSurportEmail && masterSettings.IsSurportPhone && masterSettings.SMSEnabled && !string.IsNullOrEmpty(masterSettings.SMSSettings))
            {
                this.smsenable.Value   = "true";
                this.emailenable.Value = "false";
                this.txtUserName.Attributes.Add("placeholder", "请输入用户名/手机");
                this.txtRegisterUserName.Attributes.Add("placeholder", "手机");
            }
            this.openIdType = base.GetParameter("HIGW");
            if (!string.IsNullOrEmpty(this.openIdType))
            {
                this.openIdType = this.openIdType.ToLower().Replace("_", ".");
                OpenIdSettingInfo openIdSettings = MemberProcessor.GetOpenIdSettings(this.openIdType);
                if (openIdSettings == null)
                {
                    this.AuthMsg = "没有找到对应的插件配置信息。";
                }
                else
                {
                    this.IsAuth     = true;
                    this.parameters = new NameValueCollection
                    {
                        this.Page.Request.Form,
                        this.Page.Request.QueryString
                    };
                    OpenIdNotify openIdNotify = OpenIdNotify.CreateInstance(this.openIdType, this.parameters);
                    openIdNotify.Authenticated += this.Notify_Authenticated;
                    openIdNotify.Failed        += this.Notify_Failed;
                    try
                    {
                        openIdNotify.Verify(30000, HiCryptographer.Decrypt(openIdSettings.Settings));
                    }
                    catch (Exception ex)
                    {
                        this.IsAuth  = false;
                        this.AuthMsg = ex.Message;
                    }
                    if (this.hidIsAuth != null)
                    {
                        this.hidIsAuth.Value = this.IsAuth.ToString();
                    }
                    if (this.hidAuthMsg != null)
                    {
                        this.hidAuthMsg.Value = this.AuthMsg;
                    }
                    if (this.hidOpenId != null)
                    {
                        this.hidOpenId.Value = this.openId;
                    }
                    if (this.hidOpenIdType != null)
                    {
                        this.hidOpenIdType.Value = this.openIdType;
                    }
                }
            }
        }