/// <returns></returns>
        public ActionResult ValidateCode()
        {
            CreateValidateCode objCreate = new CreateValidateCode();
            string             code      = objCreate.CreateRandomCode(6);

            Session["ValidateCode"] = code;
            return(File(objCreate.CreateValidateGraphic(code), "images/jpeg"));
        }
Beispiel #2
0
        /// <summary>
        /// 生成验证码
        /// </summary>
        /// <returns></returns>
        public ActionResult ValidateCode()
        {
            CreateValidateCode createCode = new CreateValidateCode();
            string             code       = createCode.CreateRandomCode(6);

            Session["ValidateCode"] = code.ToLower();
            return(File(createCode.CreateValidateGraphic(code), "images/jpeg"));
        }
Beispiel #3
0
        /// <summary>
        /// Add action method, call the method of generating validation code and save the validation code
        /// </summary>
        /// <returns></returns>
        public ActionResult ValidateCode()
        {
            CreateValidateCode objCreateCode = new CreateValidateCode();
            // Generate validation code
            string code = objCreateCode.CreateRandomCode(5);

            TempData["ValidateCode"] = code; // Use TempData to save data( Session mechanism)
            // Return validation code image
            return(File(objCreateCode.CreateValidateGraphic(code), "image/Jpeg"));
        }
Beispiel #4
0
        //
        // GET: /Validate/

        public ActionResult GetValidateCode()
        {
            CreateValidateCode c = new CreateValidateCode();
            var code             = c.CreateCode();

            Session["validateCode"] = code;
            var bytes = c.CreateImage(code);

            return(File(bytes, @"image/jpeg"));
        }
Beispiel #5
0
        public ActionResult GetEmailValidateCode(LogInModel model, string ValidateCode, string Option = "administartor")
        {
            bool isValidateForSend = false;
            bool sendIsOk          = false;

            //发送验证码
            ICreateEmail sendEmail = new CreateEnail();
            IGetEntity   getEntity = new GetEntity();
            //创建四位随机码
            String validateCode = CreateValidateCode.CreateValidateCodes();

            try
            {
                if (model.Account == null || model.Password == null)
                {
                    return(JavaScript(""));
                }
                Session["Administartor"] = validateCode;
                ILoinValidate log = new LoginValidate();
                if (sendIsOk == false && log.ValidateAccount(model, option: Option))
                {
                    var entity = getEntity.GetEntityForKey(model.Account,
                                                           accountSchoolDal);
                    sendIsOk = sendEmail.SeendEmail(entity.AdministratorAccount, entity.CreateAdminitratorDetialDatas.Email,
                                                    validateCode, "登陆验证");
                }
            }
            catch (Exception e)
            {
                isValidateForSend = false;
            }
            if (sendIsOk)
            {
                var createCookie = new CreateCooks();
                //创建Cookie
                var cookie = createCookie.CreateCooki(5);
                HttpContext.Response.Cookies.Add(cookie);
                isValidateForSend = true;
            }
            if (isValidateForSend)
            {
                var str = CreateJavaScript.CreateJS(5);
                return(JavaScript(str));
            }
            return(new HttpStatusCodeResult(400));
        }