Example #1
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            redirectUrl = RequestHelper.GetForm <string>("RedirectUrl");
            if (redirectUrl == string.Empty)
            {
                redirectUrl = RequestHelper.GetQueryString <string>("RedirectUrl");
            }
            string userName     = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName"));
            string userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);

            UserInfo user = UserBLL.Read(userName, userPassword);

            if (user.Id > 0)
            {
                switch (user.Status)
                {
                case (int)UserStatus.NoCheck:
                    result = "该用户未激活";
                    break;

                case (int)UserStatus.Frozen:
                    result = "该用户已冻结";
                    break;

                case (int)UserStatus.Normal:
                    user = UserBLL.ReadUserMore(user.Id);
                    UserBLL.UserLoginInit(user);
                    //保持登录状态一周
                    UserBLL.AddUserCookieWeekly(user);
                    if (redirectUrl != string.Empty)
                    {
                        ResponseHelper.Redirect(redirectUrl);
                    }
                    else
                    {
                        ResponseHelper.Redirect("/Mobile/User/Index.html");
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                result = "用户名或者密码错误";
            }
            string url = "/Mobile/User/Login.html?result=" + result;

            if (redirectUrl != string.Empty)
            {
                url += "&RedirectUrl=" + redirectUrl;
            }
            ResponseHelper.Redirect(url);
        }
Example #2
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            redirectUrl = HttpUtility.UrlDecode(RequestHelper.GetForm <string>("RedirectUrl"));
            if (redirectUrl == string.Empty)
            {
                redirectUrl = RequestHelper.GetQueryString <string>("RedirectUrl");
            }
            string   userName     = StringHelper.AddSafe(RequestHelper.GetForm <string>("UserName"));
            string   userPassword = StringHelper.Password(RequestHelper.GetForm <string>("UserPassword"), (PasswordType)ShopConfig.ReadConfigInfo().PasswordType);
            string   autoLogin    = StringHelper.SearchSafe(RequestHelper.GetForm <string>("autoLogin"));
            UserInfo user         = UserBLL.Read(userName, userPassword);

            if (user.Id > 0)
            {
                switch (user.Status)
                {
                case (int)UserStatus.NoCheck:
                    result = "该用户未激活";
                    break;

                case (int)UserStatus.Frozen:
                    result = "该用户已冻结";
                    break;

                case (int)UserStatus.Normal:
                    user = UserBLL.ReadUserMore(user.Id);
                    UserBLL.UserLoginInit(user);
                    //如果设置了自动登录则保存COOKIES一周
                    if (string.Equals(autoLogin, "1"))
                    {
                        UserBLL.AddUserCookieWeekly(user);
                    }
                    //否则不保存(关闭浏览器即失效)
                    else
                    {
                        UserBLL.AddUserCookie(user);
                    }

                    if (redirectUrl != string.Empty)
                    {
                        ResponseHelper.Redirect(redirectUrl);
                    }
                    else
                    {
                        ResponseHelper.Redirect("/User/Index.html");
                    }
                    break;

                default:
                    break;
                }
            }
            else
            {
                result = "用户名或者密码错误";
            }
            string url = "/User/Login.html?Message=" + result;

            if (redirectUrl != string.Empty)
            {
                url += "&RedirectUrl=" + redirectUrl;
            }
            ResponseHelper.Redirect(url);
        }