예제 #1
0
        void addRegSuc(string regip)
        {
            RegCompact prev;

            string key = "ip_regrates_" + regip;

            string c = UrsHelper.Cache_GetObj(key) as string;

            if (false == string.IsNullOrEmpty(c))
            {
                prev = RegCompact.Parse(c);
                prev.update(DateTime.Now);
            }
            else
            {
                prev = new RegCompact(DateTime.Now);
            }
            UrsHelper.Cache_SetObj(key, prev.ToString(), 60, 0);

            //一旦通过验证码完成注册,则将此码和ip一起作为key,添加缓存,下次提交验证码时判断,
            //是否有此session,有则怀疑重复提交相同验证码,10分钟都不允许同ip提交相同验证码,会误伤
            if (!string.IsNullOrWhiteSpace(this.regcode) && this.regcode.Length == 4)
            {
                UrsHelper.Cache_SetObj(string.Format("cache_reg_code_{0}_ip_{1}", this.regcode, regip), 1, 10, 0);
            }
        }
예제 #2
0
        private IActionResult func_exec_reg(RegModel regModel, bool isfriend, int ip, string acct, string pass, bool passismyencrypt, string tname, string idcard, string mobile, int qq, string gatesrc, string pstype, string extinfo, string regip)
        {
            //配置控制,是否需要检查注册时的验证码,一段时间之后应去掉此项判断,否则非公司正常产品的gate就绕过此内容
            if (DC2Conf.RegvcodeProducts.Contains(gatesrc) && DC2Conf.RegvcodeEnable)
            {
                //2016-1-20 对于163邮箱,没有传验证码的必须传验证码
                if (acct.ToLower().EndsWith("163.com"))
                {
                    if (string.IsNullOrEmpty(regModel.vcode) && string.IsNullOrEmpty(regModel.vregval))
                    {
                        return(createVCode(regip));
                    }
                    else
                    {
                        var retValue = decRegVal(regModel.vregval, regModel.vcode, regip);
                        if (retValue != null)
                        {
                            return(retValue);
                        }
                    }
                }
                else
                {
                    var retValue = checkRegRates(regModel.vcode, regModel.vregval, regip);
                    if (retValue != null)
                    {
                        return(retValue);
                    }
                }
            }

            UrsacctInfo userInfo = Ursacct.GetItem(acct);

            if (userInfo != null)
            {
                Hashtable htbData = new Hashtable();
                htbData.Add("number", userInfo.AcctNumber.Value);
                return(this.FuncResult(new APIReturn(10303, "帐号已存在", htbData)));
            }

            DCClass    dcc     = new DCClass();
            DicDCValue dcValue = dcc.Acct_Register(regModel, isfriend, ip, acct, pass, passismyencrypt, tname, idcard, mobile, qq, gatesrc, pstype);

            if (dcValue.Code == 0)
            {
                int number = dcValue["number"].ToInt();
                Ursuser.CreateUser(number, acct, qq, mobile, idcard, extinfo);
                Hashtable cht_rcdata = new Hashtable();
                cht_rcdata["number"] = number;
                //添加缓存
                if (ip != 0 && ip != -1)
                {
                    string          ipkey        = string.Format("check-reg-ip-{0}", ip);
                    object          obj          = UrsHelper.Cache_GetObj(ipkey);
                    List <DateTime> li_ipreglist = new List <DateTime>();
                    if (obj != null && obj is List <DateTime> )
                    {
                        li_ipreglist = (List <DateTime>)obj;
                    }
                    li_ipreglist.Add(DateTime.Now);
                    UrsHelper.Cache_SetObj(ipkey, li_ipreglist);
                }
                addRegSuc(regip);
                cht_rcdata["email"]    = regModel.email;
                cht_rcdata["mailhost"] = "http://mail" + regModel.email.Substring(regModel.email.IndexOf('@'), regModel.email.Length - regModel.email.IndexOf('@'));
                return(this.FuncResult(new APIReturn(0, "注册成功", cht_rcdata)));
            }
            else if (dcValue.Code == 65)
            {
                return(this.FuncResult(new APIReturn(10303, "帐号已存在")));
            }
            else
            {
                return(this.FuncResult(new APIReturn(10306, $"注册失败({dcValue.Code})")));
            }
        }