public FileContentResult getValidateCodeImg()
        {
            string code = MyUtils.CreateValidateNumber(4);

            Session["code"] = code.ToLower();
            byte[] bytes = MyUtils.CreateValidateGraphic(code, 120, 38);
            return(File(bytes, @"image/jpeg"));
        }
Beispiel #2
0
        public JsonResult SendValidateCode(string emailAddr, int index)
        {
            var emailR = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");

            if (!emailR.IsMatch(emailAddr))
            {
                return(Json(new SRM(false, "邮箱地址不合法")));
            }

            var code = MyUtils.CreateValidateNumber(6);

            MyEmail.SendValidateCode(code, emailAddr, currentUser.realName);

            Session["email" + index] = code.ToUpper();
            return(Json(new SRM()));
        }
        public JsonResult SendValidateCodeForReset(string userName, string emailAddr)
        {
            bool isEmailValid;

            try {
                isEmailValid = new UserSv().HasEmailRegister(userName, emailAddr);
            }
            catch (Exception ex) {
                return(Json(new SRM(ex)));
            }
            if (!isEmailValid)
            {
                return(Json(new SRM(false, "此邮箱地址与贵司在本平台登记的不匹配,请确认后重新输入再发送验证码")));
            }

            //验证通过,可以发送验证码
            var code = MyUtils.CreateValidateNumber(6);

            MyEmail.SendValidateCode(code, emailAddr, userName);

            Session["emailCode"] = code.ToUpper();

            return(Json(new SRM(true, "验证码已发送,请到邮箱收取后复制到验证文本框")));
        }