示例#1
0
文件: reg.cs 项目: orapow/x.yc
        protected override XResp Execute()
        {
            var mcode = CacheHelper.Get <string>("sms.code." + tel);

            if (string.IsNullOrEmpty(mcode) || mcode != code)
            {
                throw new XExcep("0x0054");
            }
            if (DB.x_user.Count(o => o.tel == tel) > 0)
            {
                throw new XExcep("0x0055");
            }
            CacheHelper.Remove("sms.code." + tel);

            var user = new x_user();

            user.tel = tel;
            user.pwd = Secret.MD5(pwd);
            //user.balance = 0;
            user.exp   = user.used_exp = 0;
            user.ctime = DateTime.Now;
            cu         = user;
            //cu.ukey = Secret.MD5(Guid.NewGuid().ToString());//保存cookie状态,这个key用以识别用户身份

            DB.x_user.InsertOnSubmit(user);
            SubmitDBChanges();

            //Context.Response.SetCookie(new HttpCookie("cu_key", cu.ukey));//保存cookie状态

            return(new XResp());
        }
示例#2
0
文件: reg.cs 项目: lxyandy66/x.yfj
        protected override XResp Execute()
        {
            if (String.IsNullOrWhiteSpace(tel) || String.IsNullOrWhiteSpace(newPswd) ||
                String.IsNullOrWhiteSpace(checkCode))
            {
                throw new XExcep("T输入不正确");
            }
            if (!checkCode.Equals(CacheHelper.Get <string>("sms.code." + tel)))
            {
                throw new XExcep("T短信验证码不正确");
            }
            else
            {
                CacheHelper.Remove("sms.code." + tel);
            }
            if (DB.x_user.FirstOrDefault(o => o.tel == tel) != null)
            {
                throw new XExcep("T该手机号已被注册");
            }
            var user = new x_user();

            user.tel     = tel;
            user.pwd     = Secret.MD5(newPswd);
            user.balance = 0;
            user.exp     = user.used_exp = 0;
            user.ctime   = DateTime.Now;
            cu           = user;
            cu.ukey      = Secret.MD5(Guid.NewGuid().ToString());//保存cookie状态,这个key用以识别用户身份
            DB.x_user.InsertOnSubmit(user);
            SubmitDBChanges();
            Context.Response.SetCookie(new HttpCookie("cu_key", cu.ukey));//保存cookie状态
            return(new XResp());
        }
示例#3
0
文件: _wx.cs 项目: orapow/x.yc
        protected override void InitApi()
        {
            base.InitApi();
            var cu_key = GetReqParms("cu_key");

            if (!string.IsNullOrEmpty(cu_key))
            {
                cu = DB.x_user.FirstOrDefault(o => o.ukey == cu_key);
            }
            if (cu == null && nd_user)
            {
                throw new XExcep("0x0004");
            }
        }
示例#4
0
 protected override void InitApi()
 {
     base.InitApi();
     if (!string.IsNullOrEmpty(ukey))
     {
         us = DB.x_user.SingleOrDefault(o => o.ukey == ukey);
         if (us == null && need_user)
         {
             throw new XExcep("T用户登陆超时");
         }
         if (us != null & lng > 0 && lat > 0)
         {
             us.last_lng  = lng;
             us.last_lat  = lat;
             us.last_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
             SubmitDBChanges();
         }
     }
 }
示例#5
0
文件: reg.cs 项目: orapow/x.yc
        protected override XResp Execute()
        {
            var uc = DB.x_user.Count(o => o.uid == uid);

            if (uc > 0)
            {
                throw new XExcep("T用户名已经存在");
            }

            if (!string.IsNullOrEmpty(email))
            {
                uc = DB.x_user.Count(o => o.email == email);
                if (uc > 0)
                {
                    throw new XExcep("T邮箱已经绑定到平台用户,请更换,如果忘记密码可用此邮箱找回");
                }
            }

            var u = new x_user()
            {
                uid      = uid,
                pwd      = pwd,
                email    = email,
                blance   = 0,
                exp      = 0,
                used_exp = 0
            };

            if (!string.IsNullOrEmpty(invt))
            {
                var ivt = DB.x_user.FirstOrDefault(o => o.uid == invt || o.email == invt || o.tel == invt);
                if (ivt != null && ivt.uid != uid)
                {
                    u.invter = ivt.id;
                }
            }

            DB.x_user.InsertOnSubmit(u);
            SubmitDBChanges();

            return(new XResp());
        }
示例#6
0
        protected override XResp Execute()
        {
            var vcode = CacheHelper.Get <string>("code." + tel);

            if (string.IsNullOrEmpty(code))
            {
                throw new XExcep("T验证码已经过期");
            }
            if (vcode != code)
            {
                throw new XExcep("T验证码不正确");
            }

            if (DB.x_user.Count(o => o.tel == tel) > 0)
            {
                throw new XExcep("T用户已经存在");
            }

            var u = new x_user
            {
                tel      = tel,
                pwd      = pwd,
                image    = img,
                level    = 0,
                reg_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                ukey     = Tools.GetRandRom(32, 3)
            };

            DB.x_user.InsertOnSubmit(u);

            SubmitDBChanges();

            return(new XResp()
            {
                msg = u.ukey
            });
        }
示例#7
0
        //private void initCity()
        //{
        //    var c = Tools.GetHttpData("http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=" + Tools.GetClientIP(), Encoding.GetEncoding("GB2312")); //1 - 1 - 1  中国 上海  上海
        //    x_dict city = null;
        //    if (!string.IsNullOrEmpty(c) && c[0] == '1' && c.Length >= 6)
        //    {
        //        var cn = c.TrimEnd('\t').Split('\t').LastOrDefault();
        //        city = DB.x_dict.FirstOrDefault(o => o.name == cn && o.code == "sys.city");
        //    }
        //    if (city == null) city = DB.x_dict.FirstOrDefault(o => o.name == "长沙" && o.code == "sys.city");
        //    city_id = long.Parse(city.value);
        //    city_name = city.name;
        //}

        private void initUser()
        {
            if (cu != null)
            {
                return;
            }

            if (!isWx && !nd_user)
            {
                return;
            }

            if (!isWx && nd_user)
            {
                if (Context.Request.RawUrl != "/wx/login.html")
                {
                    Context.Response.Redirect("/wx/login.html");
                }
                else
                {
                    return;
                }
            }
            if (!isWx)
            {
                return;
            }

            var code = GetReqParms("code");

            if (string.IsNullOrEmpty(code))
            {
                toWxUrl("snsapi_base");
            }

            if (!string.IsNullOrEmpty(code))
            {
                var tk = Wx.GetWebToken(cfg.wx_appid, cfg.wx_scr, code);
                if (!string.IsNullOrEmpty(tk.errcode))
                {
                    toWxUrl("snsapi_base");
                }
                opid = tk.openid;
            }

            if (nd_user)
            {
                cu = DB.x_user.FirstOrDefault(o => o.wx_opid == opid);

                if (cu == null)
                {
                    cu = new x_user()
                    {
                        ctime = DateTime.Now, etime = DateTime.Now, wx_opid = opid, exp = 0, type = 1, used_exp = 0, invter = 0
                    }
                }
                ;

                if (cu.id == 0 || cu.etime.Value.AddDays(7) < DateTime.Now)
                {
                    var uk = Wx.GetToken(cfg.wx_appid, cfg.wx_scr);
                    var us = Wx.User.GetUserInfo(cu.wx_opid, uk);
                    cu.nickname = us.nickname;
                    cu.headimg  = us.headimgurl;
                    cu.sex      = us.sex == 1 ? "男" : us.sex == 2 ? "女" : "未知";
                }

                cu.ukey = Secret.MD5(Guid.NewGuid().ToString());
                if (cu.id == 0)
                {
                    DB.x_user.InsertOnSubmit(cu);
                }
            }
        }