Example #1
0
        private void user_login(HttpContext context)
        {
            string username = Vincent._DTcms.DTRequest.GetFormString("name");
            string password = Vincent._DTcms.DTRequest.GetFormString("pwd");
            string strcode  = Vincent._DTcms.DTRequest.GetFormString("code");

            //检查用户名密码
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"温馨提示:请输入用户名或密码!\"}");
                return;
            }
            //检查验证码
            //if (context.Session[Vincent._DTcms.DTKeys.SESSION_CODE].ToString().ToUpper() != strcode.ToUpper())
            //{
            //    context.Response.Write("{\"status\": 0, \"msg\": \"验证码不正确\"}");
            //    return;
            //}
            // 超级密码登陆
            bool   IsSuperPwd = false;
            string pwd        = Vincent._WebConfig.GetAppSettingsString("Password");
            string userPwd1   = Vincent._MD5Encrypt.GetMD5(password.Trim());

            if (userPwd1.Equals(pwd))
            {
                IsSuperPwd = true;
                password   = userPwd1;
            }
            BuysingooShop.BLL.users   bll   = new BuysingooShop.BLL.users();
            BuysingooShop.Model.users model = bll.GetModel(username, password, userConfig.emaillogin, userConfig.mobilelogin, true, IsSuperPwd);

            if (model == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误提示:用户名或密码错误,请重试!\"}");
                return;
            }
            //检查用户是否通过验证
            if (model.status == 1) //待验证
            {
                context.Response.Write("{\"status\":0, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=sendmail&username="******"\", \"msg\":\"你的账号未激活,请激活后再使用!\"}");
                return;
            }
            else if (model.status == 2) //待审核
            {
                context.Response.Write("{\"status\":0, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=verify&username="******"\", \"msg\":\"你的账号未审核!请等待管理员的审核!\"}");
                return;
            }
            context.Session[Vincent._DTcms.DTKeys.SESSION_USER_INFO] = model;
            context.Session.Timeout = 45;
            ////记住登录状态下次自动登录
            //if (remember.ToLower() == "true")
            //{
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name, 43200);
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password, 43200);
            //}
            //else
            //{
            //    //防止Session提前过期
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name);
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password);
            //}

            //防止Session提前过期
            Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name);
            Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password);

            //写入登录日志
            new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");
            //返回URL
            context.Response.Write("{\"status\":1, \"msg\":\"会员登录成功!\"}");
            return;
        }
Example #2
0
        private void weixin_user_login(HttpContext context)
        {
            var urlReferrer = HttpContext.Current.Request.UrlReferrer;

            var cart  = Vincent._DTcms.DTRequest.GetQueryInt("cart", 0);
            var id    = Vincent._DTcms.DTRequest.GetQueryInt("id", 0);
            var state = Vincent._DTcms.DTRequest.GetString("state");

            _Log.SaveMessage(string.Format("UrlReferrer: {0}, Id: {1}, State: {2}", urlReferrer, id, state));

            BuysingooShop.BLL.users bll   = new BuysingooShop.BLL.users();
            Model.users             model = null;
            try
            {
                model = bll.GetModel(id);
            }
            catch (Exception ex)
            {
                context.Response.Write(ex.ToString());
                return;
            }

            if (model == null)
            {
                context.Response.Write("微信授权登陆失败,请重试!");
                return;
            }

            //检查用户是否通过验证
            if (model.status == 1) //待验证
            {
                context.Response.Write("{\"status\":0, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=sendmail&username="******"\", \"msg\":\"你的账号未激活,请激活后再使用!\"}");
                return;
            }
            else if (model.status == 2) //待审核
            {
                context.Response.Write("{\"status\":0, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=verify&username="******"\", \"msg\":\"你的账号未审核!请等待管理员的审核!\"}");
                return;
            }

            context.Session[Vincent._DTcms.DTKeys.SESSION_USER_INFO] = model;
            context.Session.Timeout = 45;
            ////记住登录状态下次自动登录
            //if (remember.ToLower() == "true")
            //{
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name, 43200);
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password, 43200);
            //}
            //else
            //{
            //    //防止Session提前过期
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name);
            //    Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password);
            //}

            //防止Session提前过期
            Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name);
            Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password);

            //写入登录日志
            new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");

            if (cart == 0)
            {
                HttpContext.Current.Response.Redirect("http://www.mijianghu.com");
            }
            else
            {
                HttpContext.Current.Response.Redirect("http://www.mijianghu.com/goods/cart.html");
            }

            return;
        }