Esempio n. 1
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="Data">用户数据组</param>
        /// <returns></returns>
        public bool Register(bk_user Data, string CodeToken)
        {
            DxCsharpSDK.Captcha         captcha  = new DxCsharpSDK.Captcha(appId, appSecret);
            DxCsharpSDK.CaptchaResponse response = captcha.VerifyToken(CodeToken);
            //确保验证状态是SERVER_SUCCESS,SDK中有容错机制,在网络出现异常的情况会返回通过
            if (!response.result)
            {
                return(false);
            }

            IQueryable <bk_user> Us;

            Us = db.UserDAL.QueryUser(Data.Us_UserName, "Us_UserName");
            if (Us.Count() >= 1)
            {
                return(false);
            }
            //设置注册时间
            Data.Us_RegisterTime = DateTime.Now.ToLocalTime();
            //对密码使用MD5加密
            Data.Us_PassWord = MD5Helper.getMD5String(Data.Us_PassWord);
            //取Ip地址
            Data.Us_Ip = IPHelper.GetExternalIp();
            //置头像
            Data.Us_ProfilePhoto = "M_Tx";
            if (Data.Us_NickName == null)
            {
                Data.Us_NickName = Data.Us_UserName;
            }
            //交给数据访问层写入数据库
            db.UserDAL.addUser(Data);
            db.saveChanges();//一键确认数据
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 校验密码
        /// </summary>
        /// <param name="UserName">用户名</param>
        /// <param name="PassWord">密码</param>
        /// <returns>返回JSON数据源</returns>
        public string Check_Pass(string UserName, string PassWord, string CodeToken, out bk_user ResultUserInfo)
        {
            string JSON = "";

            ResultUserInfo = null;
            List <bk_user> UserInfo = null;

            DxCsharpSDK.Captcha         captcha  = new DxCsharpSDK.Captcha(appId, appSecret);
            DxCsharpSDK.CaptchaResponse response = captcha.VerifyToken(CodeToken);
            //确保验证状态是SERVER_SUCCESS,SDK中有容错机制,在网络出现异常的情况会返回通过
            if (!response.result)
            {
                JSON = Json_Conver(new Response <String>
                {
                    State = -1,
                    Msg   = "验证码异常!请重新滑动!"
                });
                return(JSON);
            }
            UserInfo = db.UserDAL.QueryPwd(UserName, MD5Helper.getMD5String(PassWord)).ToList();
            if (UserInfo.Count != 0)
            {
                if (UserName == "admin")
                {
                    JSON = Json_Conver(new Response <String>
                    {
                        State = 2,
                        Msg   = MD5Helper.getMD5String(UserInfo[0].Us_Id + DateTime.Now.ToString())
                    });
                }
                else
                {
                    JSON = Json_Conver(new Response <string>
                    {
                        State = 1,
                        Msg   = MD5Helper.getMD5String(UserInfo[0].Us_Id + DateTime.Now.ToString())//加密Token
                    });
                }
                ResultUserInfo = UserInfo[0];
            }
            else
            {
                JSON = Json_Conver(new Response <String> {
                    State = -1,
                    Msg   = "登录失败,请检查您的密码或账号名!"
                });
            }
            return(JSON);
        }
Esempio n. 3
0
        /// <summary>
        /// 图片验证
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public int TuPianYanZheng(string token)
        {
            String appId     = "f4821addb462dd54853153c0c72ef42f";
            String appSecret = "4a1b54464e6af3cb0ceb4bda7816cf32";

            DxCsharpSDK.Captcha         captcha  = new DxCsharpSDK.Captcha(appId, appSecret);//DxCsharpSDK 为引用 DxCsharpSDK.dll
            DxCsharpSDK.CaptchaResponse response = captcha.VerifyToken(token);
            Response.Write(response.captchaStatus);
            //确保验证状态是SERVER_SUCCESS,SDK中有容错机制,在网络出现异常的情况会返回通过
            if (response.result)
            {
                /**token验证通过,继续其他流程**/
                return(1);
            }
            else
            {
                /**token验证失败,业务系统可以直接阻断该次请求或者继续弹验证码**/
                return(0);
            }
        }