예제 #1
0
        public async Task <ActionResult> Login(LoginViewModel vm, string returnUrl)
        {
            #region Recaptcha
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(vm));
            }
            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }
            #endregion

            if (!ModelState.IsValid)
            {
                return(View(vm));
            }


            var user = this._userSertvice.Verify(vm.EmailAddress, vm.Password);

            if (user != null)
            {
                this.SignIn(user, true);
                return(RedirectToLocal(returnUrl).Success(string.Format("Welcome back {0}!", user.Fullname)));
            }

            ModelState.AddModelError("", "Invalid email or password.");
            return(View(vm));
        }
예제 #2
0
        protected void ASPxButtonLogin_Click(object sender, EventArgs e)
        {
            Page.Validate();

            if (!Page.IsValid)
            {
                return;
            }


            if (string.IsNullOrEmpty(recaptchaUserValue.Value))
            {
                Msg.Text = "Error en los datos de seguridad, vuelva a recargar la página.";
                return;
            }


            var Recaptchav3 = new RecaptchaVerificationHelper();

            // If your site is behind CloudFlare, be sure you're suing the CF-Connecting-IP header value instead:
            // https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers

            RecaptchaVerificationResult recaptchaResult = Recaptchav3.VerifyRecaptchav3Response(
                Global.Configuration.Security.Google.Recaptcha.v3.GetGoogleRecaptchaSecretKey()
                , Global.Configuration.Security.Google.Recaptcha.v3.GetGoogleRecaptchaWebsiteKey()
                , Request.UserHostAddress
                , recaptchaUserValue.Value
                );

            if (recaptchaResult == RecaptchaVerificationResult.Success)
            {
                //divMessage.InnerHtml = "Score: " + Recaptchav3.Score;
                decimal?minScore = new decimal(0.6);
                if (Recaptchav3.Score < minScore)
                {
                    Response.Redirect("~/Captcha.aspx", true);
                }


                //create session
                // Global.Sessions.UserCreateSession();

                if (UsernameTextbox.Text.Equals(ConfigurationManager.AppSettings["Authentication:Credentials.User.Login"].ToString(), StringComparison.InvariantCulture) &&
                    PasswordTextbox.Text.Equals(ConfigurationManager.AppSettings["Authentication:Credentials.User.Password"].ToString(), StringComparison.InvariantCulture))
                {
                    Session["User.UserID"] = UsernameTextbox.Text;
                    Session.Timeout        = 60;
                    Response.Redirect("~/Admin/Main.aspx");
                }
                else
                {
                    Msg.Text = "Login failed. Please check your user name and password and try again.";
                }
            }
            else
            {
                Msg.Text = "Existe un problema para validar la seguridad, intente mas tarde o por favor contacte a soporte técnico.";
                return;
            }
        }
예제 #3
0
        public async Task <ActionResult> Index(Socioboard.Helper.Enterprise ent)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            string ret;

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                //return View(model);
                return(View());
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
                ViewBag.AlertMsg = "error";
                return(RedirectToAction("Enterprise", "Versions", new { hint = "error" }));
            }
            else
            {
                Api.MailSender.MailSender ApiobjMailSender = new Api.MailSender.MailSender();
                ret = ApiobjMailSender.SendEnterpriseMail(ent.Name, ent.Designation, ent.ContactEmailId, ent.Location, ent.Company, ent.CompanyWebsite, ent.Message, ent.Phone);

                return(RedirectToAction("Enterprise", "Versions", new { hint = "success" }));
                //return Content(ret);
                //return View();
            }


            // return View(model);
            //return View();
        }
예제 #4
0
        public async Task <ActionResult> Login(string email, string password)
        {
            Login login = new Login();

            try
            {
                if (login.RecaptchaTime())
                {
                    RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
                    if (String.IsNullOrEmpty(recaptchaHelper.Response))
                    {
                        throw new CustomException.EmptyRecaptcha();
                    }
                    RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

                    if (recaptchaResult != RecaptchaVerificationResult.Success)
                    {
                        throw new CustomException.Recaptcha();
                    }
                }
                login.LoginUser(email, password);
            }

            catch (Exception ex)
            {
                if (ex is CustomException.EmptyRecaptcha || ex is CustomException.Recaptcha)
                {
                    login.Error = ex.Message;
                }
                return(View(login));
            }
            return(Redirect("/home/index"));
        }
예제 #5
0
        public ActionResult CreateByTopic(int id, [Bind(Include = "QuoteId,TopicId,QuoteText,QuoteAuthor,QuotePassword")] Quotes quotes)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Shit's fried mate");
            }
            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }
            quotes.TopicId = id;
            if (ModelState.IsValid)
            {
                db.Quotes.Add(quotes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "TopicName", quotes.TopicId);
            return(View(quotes));
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!string.IsNullOrEmpty(_publicKey) && !string.IsNullOrEmpty(_privateKey))
            {
                var localizedResourceService = HostContainer.GetInstance <ILocalizedResourceService>();

                var controller = (Controller)HttpContext.Current.Items[FrameworkConstants.EzCurrentController];
                RecaptchaVerificationHelper recaptchaHelper = controller.GetRecaptchaVerificationHelper(_privateKey);

                if (string.IsNullOrEmpty(recaptchaHelper.Response))
                {
                    filterContext.Controller.ViewData.ModelState.AddModelError(Name,
                                                                               localizedResourceService.T("CaptchaValidation_Message_EmptyCaptcha"));
                }
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    filterContext.Controller.ViewData.ModelState.AddModelError(Name,
                                                                               localizedResourceService.T("CaptchaValidation_Message_InvalidCaptchaAnswer"));
                }
            }

            base.OnActionExecuting(filterContext);
        }
예제 #7
0
        public async Task <ActionResult> Register(string email, string password1, string password2, string name, string company)
        {
            RegisterUser userToRegister = new RegisterUser();

            try
            {
                userToRegister.Setup(email, password1, password2, name, company);
                RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
                if (String.IsNullOrEmpty(recaptchaHelper.Response))
                {
                    throw new CustomException.EmptyRecaptcha();
                }
                RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    throw new CustomException.Recaptcha();
                }
                userToRegister.Save();
                return(View());
            }
            catch (Exception ex)
            {
                if (ex is CustomException.EmptyRecaptcha || ex is CustomException.Recaptcha)
                {
                    userToRegister.Error = ex.Message;
                }
                return(View(userToRegister));
            }
        }
예제 #8
0
        public ActionResult SubmitForm(Contact model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                return(CurrentUmbracoPage());
            }
            else
            {
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect");
                    return(CurrentUmbracoPage());
                }
            }

            if (ModelState.IsValid)
            {
                //Process the valid form

                SendEmail(model);
                TempData["ContactSuccess"] = true;
                return(RedirectToCurrentUmbracoPage());
            }
            return(CurrentUmbracoPage());
        }
예제 #9
0
        public async Task <ActionResult> Feedback(FeedBackModel model)
        {
            try
            {
                RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

                if (String.IsNullOrEmpty(recaptchaHelper.Response))
                {
                    TempData["FeedbackStatus"]  = false;
                    TempData["FeedbackMessage"] = "Vui lòng nhập mã bảo mật bên dưới.";
                    return(Redirect(Request.UrlReferrer.AbsoluteUri));
                }

                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    TempData["FeedbackStatus"]  = false;
                    TempData["FeedbackMessage"] = "Vui lòng nhập lại mã bảo mật bên dưới.";
                    return(Redirect(Request.UrlReferrer.AbsoluteUri));
                }
                TempData["FeedbackStatus"] = model.InsertNewFeedback();
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
예제 #10
0
    async protected void RegisterNewUser(object sender, EventArgs e)
    {
        if (Password.Text != Reenter.Text)
        {
            Message.Text  = "The passwords do not match. Re-enter the passwords.";
            Password.Text = "";
            Reenter.Text  = "";
            return;
        }

        try
        {
            if (Useremail.Text == "" || Username.Text == "" || Password.Text == "" || Reenter.Text == "" || FirstName.Text == "" || LastName.Text == "")
            {
                Message.Text = "None of the values can be empty.";
                return;
            }


            var exists = CheckIfUserAlreadyExists(Useremail.Text);

            if (exists)
            {
                Message.Text = "You already have an account. Go back and login!";
                return;
            }

            if (String.IsNullOrEmpty(Recaptcha1.Response))
            {
                Message.Text = "Captcha cannot be empty.";
                return;
            }
            else
            {
                RecaptchaVerificationResult result = await Recaptcha1.VerifyTaskAsync();

                if (result == RecaptchaVerificationResult.Success)
                {
                    StoreData(Username.Text, Password.Text, "Member", FirstName.Text, LastName.Text, Useremail.Text);

                    Message.Text   = "Registration complete.";
                    GoBack.Visible = true;
                    return;
                }
                else if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                {
                    Message.Text = "Incorrect captcha response.";
                }
                else
                {
                    Message.Text = "Some other problem with captcha.";
                }
            }
        }
        catch (Exception exception)
        {
            Message.Text = "Could not register. Try again." + exception;
        }
    }
예제 #11
0
        public async Task <ContentResult> New(string name, string email, string comment, int ignorecaptcha = 0)
        {
            try
            {
                if (ignorecaptcha != 1)
                {
                    RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();


                    if (String.IsNullOrEmpty(recaptchaHelper.Response))
                    {
                        ModelState.AddModelError("", "Captcha answer cannot be empty.");
                        return(Content("{\"success\":false}", "text/plain"));
                    }

                    RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

                    if (recaptchaResult != RecaptchaVerificationResult.Success)
                    {
                        ModelState.AddModelError("", "Incorrect captcha answer.");
                        return(Content("{\"success\":false}", "text/plain"));
                    }
                }
                Random       rnd  = new Random();
                int          id   = rnd.Next(10000, 20000);
                StreamReader w    = new StreamReader(HostingEnvironment.MapPath("~/email.html"), true);
                var          body = await w.ReadToEndAsync();

                body = body.Replace("{name}", name).Replace("{number}", id.ToString()).Replace("{message}", comment);
                var message = new MailMessage();
                message.To.Add(new MailAddress("*****@*****.**")); // replace with valid value
                message.To.Add(new MailAddress(email));
                message.From = new MailAddress("*****@*****.**");   // replace with valid value
                message.ReplyToList.Add(email);
                message.Subject    = "Support Request #" + id;
                message.Body       = body;
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // replace with valid value
                        Password = "******"                // replace with valid value
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.epicapps.com.br";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = false;
                    await smtp.SendMailAsync(message);
                }
            }
            catch (Exception e)
            {
                return(Content("{\"success\":false, \"message\": " + e.Message + e.ToString() + "}", "text/plain"));
            }
            return(Content("{\"success\":true}", "text/plain"));
        }
예제 #12
0
        public ActionResult SubmitContactForm(ContactFormModel model) //Use ActionResult to handle the user interaction
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            //Check if reCAPTCHA has a result
            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                return(CurrentUmbracoPage());

                /* If it's an USkinned Umbraco Site:
                 *  return JavaScript("$('#recaptchaErrorMsg').show();$('#recaptchaErrorMsg').html('The reCAPTCHA field is required.');");
                 */
            }
            else
            {
                //Check if reCAPTCHA has a success result
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect!");
                    return(CurrentUmbracoPage());

                    /* If it's an USkinned Umbraco Site:
                     *  return JavaScript("$('#recaptchaFailMsg').show();$('#recaptcahFailMsg').html('The reCAPTCHA is incorrect!');");
                     */
                }
            }

            //Check if the data posted is valid
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());

                /* If it's an USkinned Umbraco Site:
                 *  return JavaScript(String.Format("$(ContactError{0}).show();$(ContactError{0}).html('{1}');", model.CurrentNodeID, HttpUtility.JavaScriptStringEncode(umbraco.library.GetDictionaryItem("USN Contact Form General Error"))));
                 */
            }

            string managerEmail = CurrentPage.HasValue("notifyEmail") ? CurrentPage.GetPropertyValue <string>("notifyEmail") : string.Empty;

            //Send email to manager
            SendNotificationToManager(model, managerEmail);

            //Send an auto replied email back to the clients
            SendAutoResponder(model);

            //Check if redirectionPage Url is empty
            var redirectionPage = CurrentPage.GetPropertyValue <Link>("redirection");

            //If it is, then redirect page to the Home page
            if (string.IsNullOrWhiteSpace(redirectionPage?.Url))
            {
                return(this.RedirectToUmbracoPage(CurrentPage.Site()));
            }
            //Otherwise, redirect it to the redirection page
            return(this.Redirect(redirectionPage.Url));
        }
예제 #13
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                return(View(model));
            }
            else
            {
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect");
                    return(View(model));
                }
            }

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Username, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                var lpUser = new LPUser();
                lpUser.Email    = model.Email;
                lpUser.Username = model.Username;
                //Used for testing
                //string[] splitstring = model.Email.Split('@');
                //lpUser.Username = splitstring[0];
                if (result.Succeeded)
                {
                    db.LPUsers.Add(lpUser);
                    db.SaveChanges();
                    CreateProfile(model.Email);
                    System.Diagnostics.Debug.WriteLine("Registered");
                    //  Comment the following line to prevent log in until the user is confirmed.
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    string callbackUrl = await SendEmailConfirmationTokenAsync(user.Id, "Confirm your account");

                    ViewBag.Message = "Check your email and confirm your account, you must be confirmed "
                                      + "before you can log in.";

                    //Call the ActionResult method that creates an LPUser
                    //return RedirectToAction("LPUserCreate", "Home", new { Email = model.Email });
                    return(View("Info"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                // If we got this far, something failed, redisplay form
                return(View(model));
            }
            else
            {
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect");
                    // If we got this far, something failed, redisplay form
                    return(View(model));
                }
            }
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //Replace this with Repository Pattern!!
                    CompanionContext db       = new CompanionContext();
                    CompanionUser    compUser = new CompanionUser();
                    compUser.ASPIdentityID = user.Id;
                    compUser.Email         = user.Email;
                    db.CompanionUsers.Add(compUser);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #15
0
        public ActionResult Create(EditOrderViewModel model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha відповідь не може бути пустою.");
                return(View("Edit", model));
            }

            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Невірна captcha відповідь.");
                return(View("Edit", model));
            }

            HttpCookie consumerBasketRawDataCookie = Request.Cookies["ConsumerBasket"];

            if (consumerBasketRawDataCookie == null)
            {
                ModelState.AddModelError("", "Не вибрано жодного товару для покупки");
            }

            if (ModelState.IsValid)
            {
                List <ProductInBasketViewModel> productInBasketViewModels = JsonConvert.DeserializeObject <List <ProductInBasketViewModel> >(
                    HttpContext.Server.UrlDecode(consumerBasketRawDataCookie.Value));

                Order order = _ordersBL.CreateOrder(new CreateOrderQuery
                {
                    Person = new CreateOrderQuery.AddPersonQuery
                    {
                        Email       = model.Email,
                        MiddleName  = model.MiddleName,
                        LastName    = model.LastName,
                        PhoneNumber = model.PhoneNumber,
                        FirstName   = model.FirstName
                    },
                    OrderedProducts = new List <CreateOrderQuery.AddOrderedProductQuery>(
                        productInBasketViewModels.Select(
                            p => new CreateOrderQuery.AddOrderedProductQuery
                    {
                        ProductId = p.Id,
                        Quantity  = p.Quantity
                    }).ToList()),
                    AdditionalComment = model.AdditionalComment
                });
                TempData[Constants.TempDataKeys.ORDER_ID] = order.Id;
                return(RedirectToAction("OrderDetails", new { orderId = order.Id }));
            }

            return(View("Edit", model));
        }
예제 #16
0
        public ActionResult RateHospital(int id = 0, int score = 0)
        {
            try
            {
                if (Session["RATING_TIME"] == null)
                {
                    Session["RATING_TIME"] = 0;
                }

                int ratingTime = (int)Session["RATING_TIME"];
                Session["RATING_TIME"] = ++ratingTime;

                if (ratingTime > 3)
                {
                    RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

                    if (String.IsNullOrEmpty(recaptchaHelper.Response))
                    {
                        TempData["RateActionStatus"]  = false;
                        TempData["RateActionMessage"] = "Vui lòng nhập mã bảo mật bên dưới.";

                        return(RedirectToAction(Constants.HospitalAction, Constants.HomeController, new { hospitalId = id, redirect = "yes" }));
                    }

                    RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

                    if (recaptchaResult != RecaptchaVerificationResult.Success)
                    {
                        TempData["RateActionStatus"]  = false;
                        TempData["RateActionMessage"] = "Vui lòng nhập lại mã bảo mật bên dưới.";

                        return(RedirectToAction(Constants.HospitalAction, Constants.HomeController, new { hospitalId = id, redirect = "yes" }));
                    }
                }

                string email = User.Identity.Name.Split(Char.Parse(Constants.Minus))[0];

                int userId = AccountModel.LoadUserIdByEmail(email);

                bool check = HomeModel.RateHospital(userId, id, score);
                if (!check)
                {
                    TempData["RateActionStatus"]  = false;
                    TempData["RateActionMessage"] = "Vui lòng thử lại sau ít phút.";
                }
                TempData["RateActionStatus"] = true;
                return(RedirectToAction(Constants.HospitalAction, Constants.HomeController, new { hospitalId = id, redirect = "yes" }));
            }
            catch (Exception exception)
            {
                LoggingUtil.LogException(exception);
                return(RedirectToAction(Constants.SystemFailureHomeAction, Constants.ErrorController));
            }
        }
예제 #17
0
        public bool CheckCaptcha(RecaptchaVerificationHelper recaptchaHelper, ref string errore)
        {
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                errore = App_GlobalResources.ErrorResource.ContactsCaptchaEmpty;
                return(false);
            }
            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                errore = App_GlobalResources.ErrorResource.ContactsCaptchaError;
                return(false);
            }
            return(true);
        }
예제 #18
0
    protected void InviaButton_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Recaptcha1.Response))
        {
            lblMessage.Text = "Inserire codice reCaptcha in basso";
        }
        else
        {
            RecaptchaVerificationResult result = Recaptcha1.Verify();

            if (result == RecaptchaVerificationResult.Success)
            {
                ////Preparo i campi della mail
                String from = "*****@*****.**";
                String to   = "*****@*****.**";
                //Istanzio la classe che rappresenta il messaggio
                MailMessage mMailMessage = new MailMessage();
                //Aggiungo il Mittente
                mMailMessage.From = new MailAddress(from);
                //Aggiungo il destinatario
                mMailMessage.To.Add(new MailAddress(to));
                mMailMessage.To.Add(new MailAddress("*****@*****.**"));
                //L'oggetto
                mMailMessage.Subject = "Richiesta informazioni da sito web";
                //Il corpo
                mMailMessage.Body = "Richiesta di informazioni ricevuta tramite il sito www.santuariodicaravaggio.eu<br/><br/><strong>Messaggio inviato da:</strong> " + NomeTextBox.Text + " " + CognomeTextBox.Text + "<br/><strong>Mail:</strong> " + MailTextBox.Text + "<br/><strong>Tel:</strong> " + TelTextBox.Text + "<br/><br/><strong>Testo del messaggio:</strong> <br/>" + RichiestaTtBox1.Text;
                //Setto la modalità testo, per il contenuto del messaggio. Sarebbe possibile inviare anche dell'HTML mettendo true
                mMailMessage.IsBodyHtml = true;
                //Setto la priorità
                mMailMessage.Priority = MailPriority.Normal;
                //configurazione nel web.config
                SmtpClient mSmtpClient = new SmtpClient();
                //Invio il messaggio
                mSmtpClient.Send(mMailMessage);
                Response.Redirect("FormResponse.aspx");
            }
            if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
            {
                lblMessage.Text = "reCaptcha inserito in modo scorretto";
            }
            else
            {
                lblMessage.Text = "C'è stato un problema, riprova.";
            }
        }
    }
예제 #19
0
        private async Task ReCapchaVerification()
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Click the thing that says 'I'm not a robot' (unless you are actually a robot, in which case go away)");
                return;
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Google says you're a bot. Sorry (notsorry)");
            }
        }
        protected void BootstrapButtonLogin_Click(object sender, EventArgs e)
        {
            divMessage.Visible = true;

            // validate captcha:
            if (Request["g-recaptcha-response"] == null)
            {
                divMessage.InnerHtml = "Error, no Captcha field form.  Intente mas tarde o por favor contacte a soporte técnico si el error persiste.";
                return;
            }

            var Recaptchav2 = new RecaptchaVerificationHelper();


            if (string.IsNullOrEmpty(Request["g-recaptcha-response"].ToString()))
            {
                divMessage.InnerHtml = "El Captcha no puede estar vacio.";
                return;
            }
            else
            {
                string secretkey = Global.Configuration.Security.Google.Recaptcha.v2.GetGoogleRecaptchaSecretKey();

                RecaptchaVerificationResult result = Recaptchav2.VerifyRecaptchaResponse(secretkey, Request["g-recaptcha-response"].ToString());

                if (result == RecaptchaVerificationResult.Success)
                {
                    //Response.Redirect( "Welcome.aspx" );
                    //divMessage.InnerHtml = "Captcha OK :D";

                    Response.Redirect("~/Admin/Login.aspx", true);
                    //Server.Transfer("~/Default.aspx", true);
                }
                else if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                {
                    divMessage.InnerHtml = "Valor de Captcha NO Valido.";
                    return;
                }
                else
                {
                    divMessage.InnerHtml = "Existe un problema para validar el captcha, intente mas tarde o por favor contacte a soporte técnico.";
                    return;
                }
            }
        }
예제 #21
0
        /// <summary>
        /// This method calls the Google ReCaptcha API..
        /// </summary>
        /// <param name="errorMsgId">The id of the form field where the error message should be displayed.</param>
        private void VerifyCaptcha(string errorMsgId)
        {
            const string CaptchaError = "The ReCaptcha checkbox is required.";
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                this.ModelState.AddModelError(errorMsgId, CaptchaError);
                return;
            }

            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                this.ModelState.AddModelError(errorMsgId, CaptchaError);
            }
        }
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // reCaptcha
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(model));
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                return(RedirectToLocal(returnUrl));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
        public ActionResult Contact(Contact contact)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(contact));
            }

            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }

            return(View(contact));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            // reCaptcha
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(model));
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email, FirstName = model.FirstName, MiddleName = model.MiddleName, LastName = model.LastName, PhoneNumber = model.PhoneNumber
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #25
0
        public async Task <ActionResult> Register(RegisterViewModel vm)
        {
            #region Recaptcha
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(vm));
            }
            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
            }
            #endregion

            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            if (this._userSertvice.EmailExist(vm.EmailAddress))
            {
                ModelState.AddModelError("EmailAddress", "Email already in use.");
                return(View(vm));
            }

            var user = new User()
            {
                Firstname         = vm.Firstname,
                Lastname          = vm.Lastname,
                EmailAddress      = vm.EmailAddress,
                ClearTextPassword = vm.Password
            };

            this._userSertvice.Add(user);

            return(RedirectToAction("Login")
                   .Success("Account successfully created."));
        }
예제 #26
0
        private bool ValidateRecaptcha()
        {
            bool recaptchaSuccess = true;

            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                recaptchaSuccess = false;
            }

            RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                ModelState.AddModelError("", "Incorrect captcha answer.");
                recaptchaSuccess = false;
            }
            return(recaptchaSuccess);
        }
예제 #27
0
        public async Task <ActionResult> Register(RegisterModel model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            //Check if Captcha is empty
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(model));
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            //Check if captcha is not a success
            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                //Return user to Register page with an error
                ModelState.AddModelError("", "Incorrect captcha answer.");
                return(View(model));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    // Attempt to register the user
                    try
                    {
                        WebSecurity.CreateUserAndAccount(model.UserName, model.Password);
                        WebSecurity.Login(model.UserName, model.Password);
                        return(RedirectToAction("Index", "Home"));
                    }
                    catch (MembershipCreateUserException e)
                    {
                        ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                    }
                }
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #28
0
 protected void BtnGetResult_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(WebAccessCodeTextBox.Text))
     {
         this.ErrorLabel.Text = GetLocalResourceObject("ErrorLabelText").ToString();
     }
     else
     {
         if (Convert.ToInt32(Session["numberIncorrectPassword"]) >= 5)
         {
             if (String.IsNullOrEmpty(Recaptcha.Response))
             {
                 this.ErrorLabel.Text = GetLocalResourceObject("CaptchaNullOrEmpty").ToString();
             }
             else
             {
                 RecaptchaVerificationResult result = Recaptcha.Verify();
                 if (result == RecaptchaVerificationResult.Success)
                 {
                     Session["numberIncorrectPassword"] = 0;
                     this.Recaptcha.Style["display"]    = "none";
                     this.ErrorLabel.Text = null;
                     GetResult();
                 }
                 if (result == RecaptchaVerificationResult.IncorrectCaptchaSolution)
                 {
                     this.ErrorLabel.Text = GetLocalResourceObject("CaptchaIncorrect").ToString();
                 }
                 else
                 {
                     GetResult();
                 }
             }
         }
         else
         {
             GetResult();
         }
     }
 }
예제 #29
0
        public async Task <ActionResult> Create(Business business)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            //Check if Captcha is empty
            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(business));
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            //Check if captcha is not a success
            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                //Return user to business page with an error
                ModelState.AddModelError("", "Incorrect captcha answer.");
                return(View(business));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    //Add the current datetime value
                    business.DateTime = System.DateTime.Now;

                    //Add business if model and captcha are valid
                    db.Businesses.Add(business);

                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(business));
                }
            }
        }
예제 #30
0
        public async Task <JsonResult> Cadastrar(FaleConosco fale)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                return(Json(new { result = "captcha_branco" }));
            }

            RecaptchaVerificationResult recaptchaResult = await recaptchaHelper.VerifyRecaptchaResponseTaskAsync();

            if (recaptchaResult != RecaptchaVerificationResult.Success)
            {
                return(Json(new { result = "captcha_error" }));
            }

            if (ModelState.IsValid)
            {
                fale.mensagem     = Utils.StripTags(fale.mensagem);
                fale.dataCadastro = DateTime.Now;
                db.FaleConosco.Add(fale);

                try
                {
                    await db.SaveChangesAsync();

                    return(Json(new { result = "success" }));
                }
                catch (Exception ex)
                {
                    return(Json(new { result = "error-" + ex.Message }));
                }
            }
            else
            {
                return(Json(new { result = "invalid" }));
            }
        }