Пример #1
0
 public void ClearLoginStatus()
 {
     try
     {
         System.Web.HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
         if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
         {
             httpCookie.Expires = System.DateTime.Now;
             System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
         }
         System.Web.HttpCookie httpCookie2 = HiContext.Current.Context.Request.Cookies["Vshop-Member"];
         if (httpCookie2 != null && !string.IsNullOrEmpty(httpCookie2.Value))
         {
             httpCookie2.Expires = System.DateTime.Now;
             System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2);
         }
         if (System.Web.HttpContext.Current.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);
             System.Web.HttpContext.Current.Response.Cookies["hishopLoginStatus"].Value = "";
         }
     }
     catch
     {
     }
 }
Пример #2
0
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            System.Web.HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                httpCookie.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            System.Web.HttpCookie httpCookie2 = HiContext.Current.Context.Request.Cookies["Vshop-Member"];
            if (httpCookie2 != null && !string.IsNullOrEmpty(httpCookie2.Value))
            {
                httpCookie2.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2);
            }
            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.Context.Response.Cookies["hishopLoginStatus"].Value = "";
            }

            HiCache.Remove("DataCache-UserLookuptable");
            this.Context.Response.Redirect(Globals.GetSiteUrls().Home, true);
        }
Пример #3
0
        private bool userRegion(string username, string password)
        {
            HiContext current = HiContext.Current;
            Member    member  = Users.GetUser(0, username, false, true) as Member;

            if (member == null || member.IsAnonymous)
            {
                this.ShowMessage("用户名或密码错误", false);
                return(false);
            }
            member.Password = password;
            LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member);

            if (loginUserStatus == LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                current.User = member;
                return(true);
            }
            if (loginUserStatus == LoginUserStatus.AccountPending)
            {
                this.ShowMessage("用户账号还没有通过审核", false);
                return(false);
            }
            if (loginUserStatus == LoginUserStatus.InvalidCredentials)
            {
                this.ShowMessage("用户名或密码错误", false);
                return(false);
            }
            this.ShowMessage("未知错误", false);
            return(false);
        }
Пример #4
0
 public void LogOut()
 {
     if (this.Context.Request.IsAuthenticated)
     {
         IUser user = HiContext.Current.User;
         FormsAuthentication.SignOut();
         HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies[string.Format("Token_{0}", user.UserId)];
         if (httpCookie != null)
         {
             httpCookie.Expires = System.DateTime.Now.AddDays(-1.0);
             HttpContext.Current.Response.Cookies.Add(httpCookie);
         }
         HttpCookie httpCookie2 = HiContext.Current.Context.Request.Cookies[string.Format("TopSession_{0}", user.UserId)];
         if (httpCookie2 != null)
         {
             httpCookie2.Expires = System.DateTime.Now.AddDays(-1.0);
             HttpContext.Current.Response.Cookies.Add(httpCookie2);
         }
         HttpCookie  authCookie = FormsAuthentication.GetAuthCookie(user.Username, true);
         IUserCookie userCookie = user.GetUserCookie();
         if (userCookie != null)
         {
             userCookie.DeleteCookie(authCookie);
         }
         Users.ClearUserCache(user);
         RoleHelper.SignOut(user.Username);
         HttpCookie httpCookie3 = this.Context.Response.Cookies["hishopLoginStatus"];
         if (httpCookie3 != null)
         {
             httpCookie3.Value = "";
         }
     }
 }
Пример #5
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);
            }
            string text = base.Request.QueryString["ot"];

            if (OpenIdPlugins.Instance().GetPluginItem(text) == null)
            {
                this.lblMsg.Text = "没有找到对应的插件,<a href=\"" + Globals.GetSiteUrls().Home + "\">返回首页</a>。";
                return;
            }
            OpenIdSettingsInfo openIdSettings = MemberProcessor.GetOpenIdSettings(text);

            if (openIdSettings == null)
            {
                this.lblMsg.Text = "请先配置此插件所需的信息,<a href=\"" + Globals.GetSiteUrls().Home + "\">返回首页</a>。";
                return;
            }
            string returnUrl = Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("OpenIdEntry_url", new object[]
            {
                text
            }));
            OpenIdService openIdService = OpenIdService.CreateInstance(text, HiCryptographer.Decrypt(openIdSettings.Settings), returnUrl);

            openIdService.Post();
        }
Пример #6
0
        public static void SetStoreAdmin(IUser user, int days, bool AutoLogin = false)
        {
            HttpCookie  authCookie = FormsAuthentication.GetAuthCookie(user.Username, false);
            IUserCookie userCookie = user.GetUserCookie();

            userCookie.WriteCookie(authCookie, days, AutoLogin);
            userCookie.WriteStoreCookie(user.Username, days);
        }
Пример #7
0
 protected override void AttachChildControls()
 {
     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);
     }
     if (!string.IsNullOrEmpty(this.Page.Request["action"]) && this.Page.Request["action"] == "Common_UserLogin")
     {
         string text  = this.UserLogin(this.Page.Request["username"], this.Page.Request["password"]);
         string text2 = string.IsNullOrEmpty(text) ? "Succes" : "Fail";
         this.Page.Response.Clear();
         this.Page.Response.ContentType = "application/json";
         string s = string.Concat(new string[]
         {
             "{\"Status\":\"",
             text2,
             "\",\"Msg\":\"",
             text,
             "\"}"
         });
         this.Page.Response.Write(s);
         this.Page.Response.End();
     }
     this.txtUserName = (System.Web.UI.WebControls.TextBox) this.FindControl("txtUserName");
     this.txtPassword = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPassword");
     this.btnLogin    = ButtonManager.Create(this.FindControl("btnLogin"));
     this.ddlPlugins  = (System.Web.UI.WebControls.DropDownList) this.FindControl("ddlPlugins");
     this.currFlag    = (System.Web.UI.WebControls.HiddenField) this.FindControl("currFlag");
     if (this.ddlPlugins != null)
     {
         this.ddlPlugins.Items.Add(new System.Web.UI.WebControls.ListItem("请选择登录方式", ""));
         System.Collections.Generic.IList <OpenIdSettingsInfo> configedItems = MemberProcessor.GetConfigedItems();
         if (configedItems != null && configedItems.Count > 0)
         {
             foreach (OpenIdSettingsInfo current in configedItems)
             {
                 this.ddlPlugins.Items.Add(new System.Web.UI.WebControls.ListItem(current.Name, current.OpenIdType));
             }
         }
         this.ddlPlugins.SelectedIndexChanged += new System.EventHandler(this.ddlPlugins_SelectedIndexChanged);
     }
     if (this.Page.Request.UrlReferrer != null && !string.IsNullOrEmpty(this.Page.Request.UrlReferrer.OriginalString))
     {
         Login.ReturnURL = this.Page.Request.UrlReferrer.OriginalString;
     }
     this.txtUserName.Focus();
     PageTitle.AddSiteNameTitle("用户登录");
     this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
 }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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);
            base.Response.Redirect("Login.aspx", true);
        }
Пример #9
0
        private string UserLogin(string userName, string password)
        {
            string result = string.Empty;
            Member member = Users.GetUser(0, userName, false, true) as Member;

            if (member == null || member.IsAnonymous)
            {
                return("用户名或密码错误");
            }
            if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
            {
                return("您不是本站会员,请您进行注册");
            }
            member.Password = password;
            LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member);

            if (loginUserStatus == LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                HiContext.Current.User = member;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                member.OnLogin();
            }
            else
            {
                if (loginUserStatus == LoginUserStatus.AccountPending)
                {
                    result = "用户账号还没有通过审核";
                }
                else
                {
                    if (loginUserStatus == LoginUserStatus.InvalidCredentials)
                    {
                        result = "用户名或密码错误";
                    }
                    else
                    {
                        result = "未知错误";
                    }
                }
            }
            return(result);
        }
Пример #10
0
        protected override void AttachChildControls()
        {
            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);
            }
            if (!string.IsNullOrEmpty(Page.Request["action"]) && (Page.Request["action"] == "Common_UserLogin"))
            {
                string str  = UserLogin(Page.Request["username"], Page.Request["password"]);
                string str2 = string.IsNullOrEmpty(str) ? "Succes" : "Fail";
                Page.Response.Clear();
                Page.Response.ContentType = "application/json";
                Page.Response.Write("{\"Status\":\"" + str2 + "\",\"Msg\":\"" + str + "\"}");
                Page.Response.End();
            }
            txtUserName = (TextBox)FindControl("txtUserName");
            txtPassword = (TextBox)FindControl("txtPassword");
            btnLogin    = ButtonManager.Create(FindControl("btnLogin"));
            ddlPlugins  = (DropDownList)FindControl("ddlPlugins");
            if (ddlPlugins != null)
            {
                ddlPlugins.Items.Add(new ListItem("请选择登录方式", ""));
                IList <OpenIdSettingsInfo> configedItems = MemberProcessor.GetConfigedItems();
                if ((configedItems != null) && (configedItems.Count > 0))
                {
                    foreach (OpenIdSettingsInfo info in configedItems)
                    {
                        ddlPlugins.Items.Add(new ListItem(info.Name, info.OpenIdType));
                    }
                }
                ddlPlugins.SelectedIndexChanged += new EventHandler(ddlPlugins_SelectedIndexChanged);
            }

            if (Page.Request.UrlReferrer != null && !string.IsNullOrEmpty(Page.Request.UrlReferrer.OriginalString))
            {
                ReturnURL = Page.Request.UrlReferrer.OriginalString;
            }

            txtUserName.Focus();
            PageTitle.AddSiteNameTitle("用户登录", HiContext.Current.Context);
            btnLogin.Click += new EventHandler(btnLogin_Click);
        }
Пример #11
0
        private void ProcessLogin(System.Web.HttpContext context)
        {
            string text  = context.Request["userName"];
            string text2 = context.Request["password"];

            if (HiContext.Current.User != null)
            {
                this.ClearLoginStatus();
            }
            if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2))
            {
                context.Response.Write(this.GetErrorJosn(101, "缺少必填参数"));
                return;
            }
            Member member = Users.GetUser(0, text, false, true) as Member;

            if (member == null)
            {
                context.Response.Write(this.GetErrorJosn(205, "用户名无效"));
                return;
            }
            member.Password = text2;
            LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member);

            if (loginUserStatus != LoginUserStatus.Success)
            {
                context.Response.Write(this.GetErrorJosn(206, "密码有误"));
                return;
            }
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Vshop-Member");
            httpCookie.Value = Globals.UrlEncode(member.Username);
            System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            HiContext.Current.User = member;
            member.OnLogin();
            string text3 = UserHelper.UpdateSessionId(member.UserId);

            member.SessionId = text3;
            Users.UpdateUser(member);
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            stringBuilder.Append("{\"result\":{");
            stringBuilder.AppendFormat("\"uid\":{0},", member.UserId);
            stringBuilder.AppendFormat("\"sessionid\":\"{0}\"", text3);
            stringBuilder.Append("}}");
            context.Response.Write(stringBuilder.ToString());
        }
Пример #12
0
 protected override void OnInit(System.EventArgs e)
 {
     if (this.Page.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);
     }
     base.OnInit(e);
 }
Пример #13
0
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            Member member = HiContext.Current.User as Member;

            if (member == null)
            {
                this.Context.Response.Redirect("/Vshop/Login.aspx", true);
            }
            //if (!string.IsNullOrEmpty(member.OpenId))
            //{
            //    member.OpenId = "";
            //    Users.UpdateUser(member);
            //}
            System.Web.HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                httpCookie.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            System.Web.HttpCookie httpCookie2 = HiContext.Current.Context.Request.Cookies["Vshop-Member"];
            if (httpCookie2 != null && !string.IsNullOrEmpty(httpCookie2.Value))
            {
                httpCookie2.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2);
            }
            System.Web.HttpCookie httpCookie3 = HiContext.Current.Context.Request.Cookies["Site_ReferralUser"];
            if (httpCookie3 != null && !string.IsNullOrEmpty(httpCookie3.Value))
            {
                httpCookie3.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie3);
            }
            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.Context.Response.Cookies["hishopLoginStatus"].Value = "";
            }
            System.Random random = new System.Random();
            this.Context.Response.Redirect("/Vshop/MemberCenter.aspx?rnd=" + random.NextDouble(), true);
        }
Пример #14
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));
            }
        }
Пример #15
0
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            if (HiContext.Current.User == null)
            {
                return;
            }
            Member member = HiContext.Current.User as Member;

            System.Web.HttpCookie httpCookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];
            if (httpCookie != null && !string.IsNullOrEmpty(httpCookie.Value))
            {
                httpCookie.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            System.Web.HttpCookie httpCookie2 = HiContext.Current.Context.Request.Cookies["Vshop-Member"];
            if (httpCookie2 != null && !string.IsNullOrEmpty(httpCookie2.Value))
            {
                httpCookie2.Expires = System.DateTime.Now;
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2);
            }
            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.Context.Response.Cookies["hishopLoginStatus"].Value = "";
            }
            if (member.AliOpenId != "")
            {
                member.AliOpenId = "";
                Users.UpdateUser(member);
            }
            this.Context.Response.Redirect("/AliOH/Login.aspx", true);
        }
Пример #16
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);
            }
        }
Пример #17
0
        protected override void AttachChildControls()
        {
            HiContext current = HiContext.Current;

            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);
                Page.Response.Cookies["hishopLoginStatus"].Value = "";
            }
            txtUserName     = (TextBox)FindControl("txtUserName");
            txtPassword     = (TextBox)FindControl("txtPassword");
            btnLogin        = (Button)FindControl("btnLogin");
            txtCode         = (TextBox)FindControl("txtCode");
            btnLogin.Click += new EventHandler(btnLogin_Click);
        }
Пример #18
0
        //控件初始经事件
        protected override void OnInit(EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            //验证域名
            if (HiContext.Current.SiteUrl != masterSettings.SiteUrl)
            {
                Context.Response.Redirect(Globals.GetSiteUrls().Home, true);
            }


            if (Page.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);
            }
            base.OnInit(e);
        }
Пример #19
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            HttpCookie cookie = HiContext.Current.Context.Request.Cookies["Token_" + HiContext.Current.User.UserId.ToString()];

            if ((cookie != null) && !string.IsNullOrEmpty(cookie.Value))
            {
                cookie.Expires = DateTime.Now;
                HttpContext.Current.Response.Cookies.Add(cookie);
            }
            if (this.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);
                this.Context.Response.Cookies["hishopLoginStatus"].Value = "";
            }
            this.Context.Response.Redirect(Globals.GetSiteUrls().Home, true);
        }
Пример #20
0
        protected void SkipSinaOpenId()
        {
            Member member = new Member(UserRole.Member);

            if (HiContext.Current.ReferralUserId > 0)
            {
                member.ReferralUserId = new int?(HiContext.Current.ReferralUserId);
            }
            member.GradeId  = MemberProcessor.GetDefaultMemberGrade();
            member.Username = this.parameters["CurrentOpenId"];
            if (string.IsNullOrEmpty(member.Username))
            {
                member.Username = "******" + this.GenerateUsername(8);
            }
            member.Email = this.GenerateUsername() + "@localhost.com";
            string text = this.GeneratePassword();

            member.Password            = text;
            member.PasswordFormat      = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed;
            member.TradePassword       = text;
            member.IsApproved          = true;
            member.RealName            = string.Empty;
            member.Address             = string.Empty;
            if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
            {
                member.Username = "******" + this.GenerateUsername(9);
                member.Password = (member.TradePassword = text);
                if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                {
                    member.Username = this.GenerateUsername();
                    member.Email    = this.GenerateUsername() + "@localhost.com";
                    member.Password = (member.TradePassword = text);
                    if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created)
                    {
                        base.Response.Write("为您创建随机账户时失败,请重试。");
                        return;
                    }
                }
            }
            UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]);
            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }
            if (!string.IsNullOrEmpty(this.parameters["token"]))
            {
                System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                httpCookie.Value   = this.parameters["token"];
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Пример #21
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            HiContext current            = HiContext.Current;
            string    usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType);

            if (!string.IsNullOrEmpty(usernameWithOpenId))
            {
                Member member = Users.GetUser(0, usernameWithOpenId, false, true) as Member;
                if (member == null)
                {
                    base.Response.Write("登录失败,信任登录只能用于会员登录。");
                    return;
                }
                if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                {
                    base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                    return;
                }
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                IUserCookie           userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                HiContext.Current.User = member;
                ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();
                current.User = member;
                if (cookieShoppingCart != null)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                    ShoppingCartProcessor.ClearCookieShoppingCart();
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + HiContext.Current.User.UserId.ToString());
                    httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value   = this.parameters["token"];
                    System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                string a;
                if ((a = this.openIdType.ToLower()) != null)
                {
                    if (a == "Ecdev.plugins.openid.alipay.alipayservice")
                    {
                        this.SkipAlipayOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.qq.qqservice")
                    {
                        this.SkipQQOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.taobao.taobaoservice")
                    {
                        this.SkipTaoBaoOpenId();
                        goto IL_1EF;
                    }
                    if (a == "Ecdev.plugins.openid.sina.sinaservice")
                    {
                        this.SkipSinaOpenId();
                        goto IL_1EF;
                    }
                }
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
IL_1EF:
            string a2 = this.parameters["HITO"];

            if (a2 == "1")
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder"));
                return;
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }
Пример #22
0
        private void Login()
        {
            string userid    = Request["userid"];
            string userdata  = Request["userdata"];
            string timestamp = Request["timestamp"];
            string source    = Request["source"];

            if (string.IsNullOrWhiteSpace(userid) ||
                string.IsNullOrWhiteSpace(userdata) ||
                string.IsNullOrWhiteSpace(timestamp) ||
                string.IsNullOrWhiteSpace(source))
            {
                Response.Write("fail,缺少必要参数");
                Response.End();
            }

            string key = ConfigurationManager.AppSettings["Key_CCB"];
            string iv  = ConfigurationManager.AppSettings["IV_CCB"];

            string dataKey     = Cryptographer.DESDecrypt(userdata, key, iv);
            string deUserId    = Cryptographer.DESDecrypt(userid, dataKey, iv);
            string deTimestamp = Cryptographer.DESDecrypt(timestamp, dataKey, iv);

            if (string.IsNullOrWhiteSpace(dataKey) ||
                string.IsNullOrWhiteSpace(deUserId) ||
                string.IsNullOrWhiteSpace(deTimestamp))
            {
                Response.Write("fail,请求参数无效");
                Response.End();
            }

            DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(new TimeSpan(long.Parse(deTimestamp + "0000000")));
            TimeSpan span = DateTime.Now - time;

            if (span.TotalSeconds > 60)
            {
                Response.Write("fail,请求已过期");
                Response.End();
            }

            Member member = Users.GetUserByCcbOpenId(deUserId) as Member;

            if (member == null)
            {
                // fail,返回原因
                Response.Write("fail,用户不存在");
                Response.End();
            }

            System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
            IUserCookie           userCookie = member.GetUserCookie();

            userCookie.WriteCookie(authCookie, 30, false);
            ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart();

            HiContext.Current.User = member;
            if (cookieShoppingCart != null)
            {
                ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart);
                ShoppingCartProcessor.ClearCookieShoppingCart();
            }

            // 登录成功跳转到海美生活用户中心
            Response.Redirect("/User/UserDefault.aspx");
        }
Пример #23
0
        private void btnAdminLogin_Click(object sender, System.EventArgs e)
        {
            if (this.imgCode.Visible && !HiContext.Current.CheckVerifyCode(this.txtCode.Text.Trim()))
            {
                this.ShowMessage("验证码不正确");
                return;
            }

            IUser user = Users.GetUser(0, this.txtAdminName.Text, false, true);

            if (user == null || user.IsAnonymous || user.UserRole != UserRole.SiteManager)
            {
                this.ShowMessage("无效的用户信息");
                this.SetErrorTimes("username");
                return;
            }

            string      url         = null;
            SiteManager siteManager = user as SiteManager;

            siteManager.Password = this.txtAdminPassWord.Text;
            LoginUserStatus loginUserStatus = ManagerHelper.ValidLogin(siteManager);

            if (loginUserStatus == LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(siteManager.Username, false);
                IUserCookie           userCookie = siteManager.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Admin-system");
                httpCookie.Value   = siteManager.Username;
                httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                HiContext.Current.User = siteManager;
                this.RemoveCache();
                if (!string.IsNullOrEmpty(this.Page.Request.QueryString["returnUrl"]))
                {
                    url = this.Page.Request.QueryString["returnUrl"];
                }
                if (url == null && this.ReferralLink != null && !string.IsNullOrEmpty(this.ReferralLink.Trim()))
                {
                    url = this.ReferralLink;
                }
                if (!string.IsNullOrEmpty(url) && (url.ToLower().IndexOf(Globals.GetSiteUrls().Logout.ToLower()) >= 0 || url.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("register").ToLower()) >= 0 || url.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("vote").ToLower()) >= 0 || url.ToLower().IndexOf("loginexit") >= 0))
                {
                    url = null;
                }
                System.Web.HttpCookie nowcookie = new System.Web.HttpCookie("Supplier");
                if (siteManager.IsInRole("供货商"))
                {
                    nowcookie.Value   = "Supplier";
                    nowcookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    System.Web.HttpContext.Current.Response.Cookies.Add(nowcookie);
                }
                else
                {
                    nowcookie.Value   = "";
                    nowcookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    System.Web.HttpContext.Current.Response.Cookies.Add(nowcookie);
                }
                if (url != null)
                {
                    this.Page.Response.Redirect(url, true);
                    return;
                }
                this.Page.Response.Redirect("default.html", true);
                return;
            }
            else
            {
                if (loginUserStatus == LoginUserStatus.AccountPending)
                {
                    this.SetErrorTimes("username");
                    this.ShowMessage("用户账号还没有通过审核");
                    return;
                }
                if (loginUserStatus == LoginUserStatus.AccountLockedOut)
                {
                    this.SetErrorTimes("username");
                    this.ShowMessage("用户账号已被锁定,暂时不能登录系统");
                    return;
                }
                if (loginUserStatus == LoginUserStatus.InvalidCredentials)
                {
                    this.SetErrorTimes("username");
                    this.ShowMessage("用户名或密码错误");
                    return;
                }
                this.SetErrorTimes("username");
                this.ShowMessage("登录失败,未知错误");
                return;
            }
        }