public ActionResult Index(string name)
        {
            var captchaResponse = Request.Form["g-Recaptcha-Response"];
            var result          = ReCaptchaValidator.IsValid(captchaResponse);

            if (!result.Success)
            {
                if (result.ErrorCodes == null)
                {
                    result.ErrorCodes = new List <string>()
                    {
                        "NOT_HUMAN"
                    };
                }

                foreach (string err in result.ErrorCodes)
                {
                    ModelState.AddModelError("", err);
                }
            }

            result.Name = name;

            return(View(result));
        }
Exemplo n.º 2
0
        public IActionResult Select(string normal, string hard, string workSequences, string inputOrganization, string power, string current, string speed, string cos, string problem, string email)
        {
            string captchaResponse           = HttpContext.Request.Form["g-Recaptcha-Response"];
            ReCaptchaValidationResult result = ReCaptchaValidator.IsValid(captchaResponse);

            if (!result.Success)
            {
                return(RedirectToAction("Index"));
            }
            _emailService.SendSelect(normal, hard, workSequences, inputOrganization, power, current, speed, cos, problem, email);
            return(RedirectToAction("SuccessSelect"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Order(string name, string org, string post, string email, string phone, int lineId)
        {
            string captchaResponse           = HttpContext.Request.Form["g-Recaptcha-Response"];
            ReCaptchaValidationResult result = ReCaptchaValidator.IsValid(captchaResponse);

            if (!result.Success)
            {
                return(RedirectToAction("Index"));
            }
            ModelLine line = await _modelLineService.GetAsync(p => p.Id == lineId);

            _emailService.SendOrder(name, org, post, email, phone, line);
            return(RedirectToAction("SuccessOrder", new { name = line.Name }));
        }
        public async Task <IActionResult> SendConfigurationRefs(string email, string phone,
                                                                string teSys1FullRef, string teSys1CircuitBreakersRef, string teSys1CoilRef, string teSys1ContactorRef,
                                                                string teSys2FullRef, string teSys2CircuitBreakersRef, string teSys2CoilRef, string teSys2ContactorRef)
        {
            string captchaResponse           = HttpContext.Request.Form["g-Recaptcha-Response"];
            ReCaptchaValidationResult result = ReCaptchaValidator.IsValid(captchaResponse);

            if (!result.Success)
            {
                return(RedirectToAction("Index"));
            }
            _emailService.SendConfigurationRefs(email, phone,
                                                teSys1FullRef, teSys1CircuitBreakersRef, teSys1CoilRef, teSys1ContactorRef,
                                                teSys2FullRef, teSys2CircuitBreakersRef, teSys2CoilRef, teSys2ContactorRef);
            return(RedirectToAction("Success"));
        }
Exemplo n.º 5
0
        public IActionResult Login(IFormCollection collection, string captcha)
        {
            var formUserName = collection["UserName"].ToString();
            var formPin      = collection["Pin"].ToString();

            if (!int.TryParse(formPin, out _))
            {
                return(RedirectToAction("Login", "Login"));
            }

            var model = new LoginViewModel
            {
                UserName = formUserName,
                Pin      = int.Parse(formPin)
            };

            var validateModel = _bankService.ValidateUserNameAndPin(model);

            if (validateModel != true)
            {
                return(RedirectToAction("Login", "Login"));
            }

            HttpContext.Session.SetString("CurrentUserName", model.UserName);
            HttpContext.Session.SetInt32("CurrentUserPin", model.Pin);

            // this is response by div id
            var captchaResponse = Request.Form["g-Recaptcha-Response"];

            // here we validate response
            var result = ReCaptchaValidator.IsValid(captchaResponse);

            // if captcha failed -- return to login form again
            if (!result.Success)
            {
                return(RedirectToAction("Login", "Login"));
            }

            return(RedirectToAction("SuccessLoginScreen", "Login"));
        }