Beispiel #1
0
 public ActionResult MemberForgotPassword(ResetPasswordForm model)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(PartialView("~/Views/Partials/User/ForgotPassword/_Form.cshtml", model));
         }
         var member = Services.MemberService.GetByEmail(model.Username);
         if (member != null && member.IsApproved)
         {
             var newPassword = Utils.CreateRandomPassword(10);
             Services.MemberService.SavePassword(member, newPassword);
             BackgroundJobs.SendMail.EnqueueForgotPassword(model.Username, Umbraco.GetDictionaryValue("Title.ResetPassword"), newPassword);
             model.IsSuccess    = true;
             model.ResponseText = Umbraco.GetDictionaryValue("SendMail.NewPassword.Success");
             return(PartialView("~/Views/Partials/User/ForgotPassword/_Form.cshtml", model));
         }
         model.IsSuccess    = false;
         model.ResponseText = Umbraco.GetDictionaryValue("Account.NotExits");
         return(PartialView("~/Views/Partials/User/ForgotPassword/_Form.cshtml", model));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Beispiel #2
0
        public IHttpActionResult GetMemberPost()
        {
            var payload = new PayloadResult();

            if (userService.IsAuthenticated())
            {
                payload.SetOrUpdate(nameof(PayloadFields.User), userService.MapAsMember(userService.CurrentUser));
                payload.SetMessageType(GenericMessages.Success);
            }
            else if (Members.IsLoggedIn())
            {
                AddCurrentMemberToPayload(ref payload);
                payload.SetMessageType(GenericMessages.Success);
            }
            else
            {
                payload.SetMessageType(GenericMessages.Danger);
                payload.SetMessage(Umbraco.GetDictionaryValue("Members.LoginExpired", "Members.LoginExpired"));
                payload.SetOrUpdate(nameof(PayloadFields.Status), MemberStatus.LoginExpired);

                return(Error(payload));
            }

            return(Json(payload));
        }
        public ActionResult SendContactEmail(ContactViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            var from     = Umbraco.GetDictionaryValue("Contact.From");
            var template =
                Umbraco.ReplaceLineBreaksForHtml(Umbraco.GetDictionaryValue("Contact.Message"));

            var replacements = new Dictionary <string, string>();

            replacements.Add("{{name}}", model.Name);
            replacements.Add("{{email}}", model.Email);
            replacements.Add("{{message}}", model.Message);

            try
            {
                SmtpClient  client  = new SmtpClient();
                MailMessage message = new MailMessage(from, model.ToAddress);
                message.Body       = template.ReplaceMany(replacements);
                message.IsBodyHtml = true;
                client.Send(message);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Failed to send message : " + ex.Message);
            }

            return(RedirectToCurrentUmbracoPage());
        }
        public ActionResult SendContactEmail(ContactViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            var from     = Umbraco.GetDictionaryValue("Contact.From");
            var template =
                Umbraco.ReplaceLineBreaksForHtml(Umbraco.GetDictionaryValue("Contact.Message"));

            try
            {
                SmtpClient  client = new SmtpClient();
                MailMessage msg    = new MailMessage(from, model.ToAddress);

                msg.Body = template.Replace("{{name}}", model.Name)
                           .Replace("{{email}}", model.Email)
                           .Replace("{{message}}", model.Message);

                msg.IsBodyHtml = true;
                client.Send(msg);
            }
            catch (Exception ex)
            {
                TempData.Add("ContactError", "Failed to Send Message: " + ex.ToString());
            }

            return(RedirectToCurrentUmbracoPage());
        }
        public ActionResult RenderVerifyEmail(string guid)
        {
            Logger.Info <ForumAuthSurfaceController>("Verifiing: {0}", guid);

            var memberService = Services.MemberService;

            if (Guid.TryParse(guid, out var userKey))
            {
                var member = memberService.GetByKey(userKey);

                if (member != null)
                {
                    member.SetValue(ForumAuthConstants.AccountVerifiedProperty, true);
                    memberService.Save(member);
                    TempData["returnUrl"] = "/login";
                    return(Content(Umbraco.GetDictionaryValue("MemberAuth.Verfiy.Verified", "Account has been verified")));
                }
                else
                {
                    return(Content(
                               Umbraco.GetDictionaryValue("MemberAuth.Verfiy.NoMatch", "Can't find an account that matches")));
                }
            }
            else
            {
                return(Content(
                           Umbraco.GetDictionaryValue("MemberAuth.Verify.InvalidCode", "Not a valid account verification")));
            }
        }
Beispiel #6
0
        public ContentResult Dictionary()
        {
            ContentResult result = new ContentResult();

            result.Content = Umbraco.GetDictionaryValue("Test");

            return(result);
        }
Beispiel #7
0
        public IHttpActionResult HasAccessPost()
        {
            var payload = new PayloadResult();

            if (userService.IsAuthenticated())
            {
                ContextService.UserHelper.LoginAsMember();
                payload.SetMessageType(GenericMessages.Success);
            }
            //else if (CurrentPage.DocumentTypeAlias.Equals(nameof(LoginPageModel)))
            //{
            //    payload.SetMessageType(GenericMessages.Success);
            //}
            else if (Umbraco.IsProtected(CurrentPage.Path))
            {
                // Do we have a logged in member ?
                if (Umbraco.MemberIsLoggedOn() == false)
                {
                    payload.SetMessageType(GenericMessages.Danger);
                    payload.SetMessage(Umbraco.GetDictionaryValue("Members.LoginExpired", "Members.LoginExpired"));
                    payload.SetOrUpdate(nameof(PayloadFields.Status), MemberStatus.LoginExpired);

                    return(Error(payload));
                }

                // Do we have access to the current page ?
                if (Umbraco.MemberHasAccess(CurrentPage.Path) == false)
                {
                    // If we get here the member has no access to this page, redirect them to there start page.
                    payload.SetMessageType(GenericMessages.Danger);
                    RedirectCurrentMemberToStartPage(ref payload);
                    payload.SetOrUpdate(nameof(PayloadFields.Status), MemberStatus.AuthorizationFailure);
                }
                else
                {
                    // Check if the backoffice user is signed out while the admin member is logged in.
                    var member = (MemberPublishedContent)Umbraco.MembershipHelper.GetCurrentMember();
                    if (member.DocumentTypeAlias.Equals(nameof(AdminMember)) && userService.ValidateUser(member.Email))
                    {
                        var user = Services.UserService.GetByEmail(member.Email);

                        // This is a backoffice member lets log them in.
                        UmbracoContext.Security.PerformLogin(user.Id);
                        payload.SetOrUpdate(nameof(PayloadFields.Status), MemberStatus.AdminLoggedIn);
                    }

                    payload.SetMessageType(GenericMessages.Success);
                }
            }
            else
            {
                payload.SetMessageType(GenericMessages.Success);
            }

            return(Json(payload));
        }
Beispiel #8
0
        public string SmartTranslationPost(
            string key,
            [ModelBinder(typeof(AttemptingModelBinder))] JObject value,
            string altText = "")
        {
            var dictionaryValue = Umbraco.GetDictionaryValue(key, altText);
            var valueDict       = value.ToObject <Dictionary <string, object> >();

            return(Smart.Format(dictionaryValue, valueDict));
        }
        public ActionResult ForgotPassword(ForgotPasswordViewModel model)
        {
            var changePasswordSucceeded = true;
            var newPassword             = MembershipHelper.GeneratePassword();

            try
            {
                if (ModelState.IsValid)
                {
                    var currentUser = MembershipHelper.MapMember(Services.MemberService.GetByEmail(model.EmailAddress));
                    if (currentUser != null)
                    {
                        changePasswordSucceeded = MembershipHelper.ResetPassword(currentUser, newPassword);
                    }
                    else
                    {
                        changePasswordSucceeded = false;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <LoginRegisterController>(string.Format("Error resetting password for {0}", model.EmailAddress), ex);
                changePasswordSucceeded = false;
            }

            if (changePasswordSucceeded)
            {
                // ToDo: Send email.
                //var sb = new StringBuilder();
                //sb.AppendFormat("<p>{0}</p>", Umbraco.GetDictionaryValue("Members.ForgotPassword.Email"));
                //sb.AppendFormat("<p><b>{0}</b></p>", newPassword);
                //var email = new Email
                //{
                //    EmailFrom = Constants.DefaultEmailAddress,
                //    EmailTo = currentUser.Email,
                //    NameTo = currentUser.UserName,
                //    Subject = Umbraco.GetDictionaryValue("Members.ForgotPassword.Subject")
                //};
                //email.Body = ServiceFactory.EmailService.EmailTemplate(email.NameTo, sb.ToString());
                //ServiceFactory.EmailService.SendMail(email);

                // We use temp data because we are doing a redirect
                var payload = new PayloadResult();
                payload.SetMessage(Umbraco.GetDictionaryValue("Members.ForgotPassword.SuccessMessage", "Members.ForgotPassword.SuccessMessage"));
                payload.SetMessageType(GenericMessages.Success);
                ShowMessage(new PayloadResult(Umbraco.GetDictionaryValue("Members.ForgotPassword.SuccessMessage"), GenericMessages.Success));

                return(CurrentUmbracoPage());
            }

            ModelState.AddModelError(string.Empty, Umbraco.GetDictionaryValue("Members.ForgotPassword.ErrorMessage"));

            return(CurrentUmbracoPage());
        }
 public JsonResult CheckForValidEmail(string emailAddress)
 {
     if (IsValidEmailDomain(emailAddress))
     {
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(Umbraco.GetDictionaryValue("MemberAuth.Register.InvalidDomain", "There was a problem with your email address"), JsonRequestBehavior.AllowGet));
     }
 }
        private string Localize(string key, string defaultValue)
        {
            var dictionaryValue = Umbraco.GetDictionaryValue(key);

            if (string.IsNullOrEmpty(dictionaryValue))
            {
                return(defaultValue);
            }

            return(dictionaryValue);
        }
 public JsonResult CheckForEmailAddress(string emailAddress)
 {
     if (EmailAddressExists(emailAddress))
     {
         return(Json(Umbraco.GetDictionaryValue("MemberAuth.Register.ExistingEmail", "Email Address is already in use"), JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(true, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #13
0
        public IHttpActionResult GetValidationServiceMessagesPost()
        {
            var result = new Dictionary <string, object>();

            foreach (var key in validationKeys)
            {
                result.Add(key, Umbraco.GetDictionaryValue($"ValidationMessage.{key.ToFirstUpper()}"));
            }

            return(Json(result));
        }
Beispiel #14
0
 public ActionResult MemberSignUp(RegisterForm model)
 {
     try
     {
         var domainName      = Request.Url?.GetLeftPart(UriPartial.Authority);
         var culture         = CultureInfo.CurrentCulture;
         var currentHomePage = Services.ContentService.GetRootContent().First(x => x.GetCulture().Name == culture.Name);
         var verifySignUp    = currentHomePage?.Children().FirstOrDefault(x => x.ContentType.Alias == "memberInfo")?.Children().FirstOrDefault(x => x.ContentType.Alias == "verifySignUp");
         var verifyLink      = "";
         if (verifySignUp != null)
         {
             verifyLink = new RenderModel(Umbraco.TypedContent(verifySignUp.Id), culture).Content.Url;
         }
         if (model.IsSendMail == false)
         {
             System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(model.CultureLcid);
             if (!ModelState.IsValid)
             {
                 return(PartialView("~/Views/Partials/User/SignUp/_Form.cshtml", model));
             }
             var member = Services.MemberService.GetByEmail(model.Username);
             if (member == null)
             {
                 var newMember = Services.MemberService.CreateMember(model.Username, model.Username, model.FirstName + " " + model.LastName, "Member");
                 newMember.SetValue("firstName", model.FirstName);
                 newMember.SetValue("lastName", model.LastName);
                 newMember.SetValue("phoneNumber", model.PhoneNumber);
                 newMember.SetValue("address", model.Address);
                 newMember.IsApproved = false;
                 newMember.Name       = model.FirstName + " " + model.LastName;
                 Services.MemberService.Save(newMember);
                 Services.MemberService.SavePassword(newMember, model.Password);
                 model.IsRegisterSuccess = true;
                 model.IsSendMail        = true;
                 BackgroundJobs.SendMail.EnqueueRegister(model.Username, "Email xác nhận tài khoản", domainName, verifyLink);
                 return(PartialView("~/Views/Partials/User/SignUp/_Form.cshtml", model));
             }
             model.IsRegisterSuccess = false;
             model.ResponseText      = Umbraco.GetDictionaryValue("Email.Exits");
             return(PartialView("~/Views/Partials/User/SignUp/_Form.cshtml", model));
         }
         model.IsRegisterSuccess = true;
         model.IsSendMail        = true;
         BackgroundJobs.SendMail.EnqueueRegister(model.Username, "Email xác nhận tài khoản", domainName, verifyLink);
         return(PartialView("~/Views/Partials/User/SignUp/_Form.cshtml", model));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
 public ActionResult Logout()
 {
     if (Members.IsLoggedIn())
     {
         Members.Logout();
         TempData["returnUrl"] = "/forums";
         return(Content(Umbraco.GetDictionaryValue("MemberAuth.Logout.LoggedOut", "You have been logged out")));
     }
     else
     {
         return(Content(Umbraco.GetDictionaryValue("MemberAuth.Logout.NotLoggedIn", "Wasn't logged in")));
     }
 }
        private string GetDictionaryOrDefault(string key, string defaultValue)
        {
            LogHelper.Info <SimpilyAuthSurfaceController>("Getting Dictionary Value: {0} {1}", () => key, () => defaultValue);

            var dictionaryValue = Umbraco.GetDictionaryValue(key);

            if (string.IsNullOrEmpty(dictionaryValue))
            {
                return(defaultValue);
            }

            return(dictionaryValue);
        }
        public ActionResult RenderLogin()
        {
            ForumLoginViewModel login = new ForumLoginViewModel();

            Logger.Info <ForumAuthSurfaceController>("Login URL: {0}", HttpContext.Request.Url?.AbsolutePath);

            login.ReturnUrl = HttpContext.Request.Url?.ToString();
            if (HttpContext.Request.Url?.AbsolutePath == Umbraco.GetDictionaryValue("ForumAuthConstants.LoginUrl", "/login").TrimEnd('/'))
            {
                login.ReturnUrl = "/forums";
            }

            return(PartialView(Umbraco.GetDictionaryValue("ForumAuthConstants.LoginView", "Member/ForumAuth.Login"), login));
        }
Beispiel #18
0
 public ActionResult MemberLoginPage(LoginPageForm model)
 {
     try
     {
         System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(model.CultureLcid);
         if (!ModelState.IsValid)
         {
             return(PartialView("~/Views/Partials/User/Login/LoginPage/_Form.cshtml", model));
         }
         var member = Services.MemberService.GetByEmail(model.Username);
         if (member != null && member.IsApproved)
         {
             var culture         = CultureInfo.CurrentCulture;
             var currentHomePage = Services.ContentService.GetRootContent().First(x => x.GetCulture().Name == culture.Name);
             var link            = "/";
             if (currentHomePage != null)
             {
                 link = new RenderModel(Umbraco.TypedContent(currentHomePage.Id), culture).Content.Url;
             }
             if (!Members.Login(model.Username, model.Password))
             {
                 model.IsSuccess      = false;
                 model.IsRunScripts   = true;
                 model.ResponseText   = Umbraco.GetDictionaryValue("Login.Failure");
                 model.ResponseHeader = "Error!!";
                 return(PartialView("~/Views/Partials/User/Login/LoginPage/_Form.cshtml", model));
             }
             model.IsSuccess      = true;
             model.IsRunScripts   = true;
             model.ResponseText   = Umbraco.GetDictionaryValue("Login.Success");
             model.ResponseHeader = "Success!!";
             model.RedirectLink   = link;
             return(PartialView("~/Views/Partials/User/Login/LoginPage/_Form.cshtml", model));
         }
         model.IsSuccess      = false;
         model.IsRunScripts   = true;
         model.ResponseText   = Umbraco.GetDictionaryValue("Account.NotExits");
         model.ResponseHeader = "Error!!";
         return(PartialView("~/Views/Partials/User/Login/LoginPage/_Form.cshtml", model));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Beispiel #19
0
        public ActionResult Index()
        {
            var model = GetModel <DepositPageViewModel>(CurrentPage);

            if (string.IsNullOrEmpty(model.Token))
            {
                return(Redirect("/?login=y"));
            }

            model.PredefinedAmounts = new string[] { };
            if (CurrentPage.HasValue("predefinedAmountsV2"))
            {
                var predefinedAmountsList = CurrentPage.Value <IEnumerable <IPublishedElement> >("predefinedAmountsV2")
                                            .Select(x => new PredefinedAmount(x));

                var customerPredefinedAmount = predefinedAmountsList.FirstOrDefault(x => x.Currency == model.CustomerSummary.CurrencyCode);
                if (customerPredefinedAmount != null)
                {
                    model.PredefinedAmounts = customerPredefinedAmount.Amounts;
                }
            }

            var isConfirmed = Request.QueryString["isConfirmed"] != null && Convert.ToBoolean(Request.QueryString["isConfirmed"]);

            model.ShowReceipt = isConfirmed;

            if (model.ShowReceipt)
            {
                decimal gift;
                decimal bonus;
                model.Receipt = new ReceiptModel
                {
                    PaymentMethod     = Umbraco.GetDictionaryValue("[Cards]CreditCard", "Credit Card"),
                    PaymentSystemName = Session["t_name"]?.ToString(),
                    Name              = model.CustomerSummary?.Username,
                    Amount            = Session["t_amount"]?.ToString(),
                    Date              = Session["t_date"]?.ToString(),
                    Status            = isConfirmed ? Umbraco.GetDictionaryValue("[Cards]Accepted", "Accepted") : Umbraco.GetDictionaryValue("[Cards]Rejects", "Rejected"),
                    TransactionNumber = Session["t_id"]?.ToString(),
                    Gift              = decimal.TryParse(Request.QueryString["gift"], out gift) ? String.Format("{0:0.0}", Math.Truncate(gift * 10) / 10): "0.0",
                    Bonus             = decimal.TryParse(Request.QueryString["bonus"], out bonus) ? String.Format("{0:0.0}", Math.Truncate(bonus * 10) / 10) : "0.0"
                };
            }

            return(CurrentTemplate(model));
        }
Beispiel #20
0
    protected override ValidationResult IsValid(object value, ValidationContext validationContext)
    {
        var passengerDetails = value as Passenger_Details;

        if (passengerDetails == null)
        {
            // handle depending on your situation
        }

        if (string.IsNullOrWhiteSpace(passengerDetails.Phone_Mobile) &&
            string.IsNullOrWhiteSpace(passengerDetails.Phone_Home) &&
            string.IsNullOrWhiteSpace(passengerDetails.Phone_Work))
        {
            return(new ValidationResult(Umbraco.GetDictionaryValue("Booking.Validation.OnePhoneRequired")));
        }

        return(null);
    }
Beispiel #21
0
        public IHttpActionResult SendConfirmationMailPost(string email)
        {
            var result      = new PayloadResult();
            var member      = Members.GetByEmail(email);
            var wellaMember = ContextService.MembershipHelper.MapMember(member);

            wellaMember.SecurityToken = Guid.NewGuid().ToString();
            ContextService.MembershipHelper.ReverseMapMember(wellaMember, true);
            var loginPage = CurrentPage.ToModel <BaseContentModel>().StartPage.Children <LoginPageModel>().First();
            var returnUrl = loginPage.UrlWithDomain() + "?confirmEmailToken=" + wellaMember.SecurityToken;

            ContextService.Mailer.SendEmailConfirmation(wellaMember, returnUrl);

            result.SetMessage(
                Umbraco.GetDictionaryValue("Members.AuthorisationEmailSent", "Members.AuthorisationEmailSent"));
            result.SetMessageType(GenericMessages.Success);
            return(Json(result));
        }
        public ActionResult HandleContactForm(ContactForm model)
        {
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(model.CultureLCID);
            if (!ModelState.IsValid)
            {
                model.ErrorMsg = Umbraco.GetDictionaryValue("Send.Failure");
                return(PartialView("~/Views/Partials/Contact/_Form.cshtml", model));
            }
            var domainName    = Request.Url?.GetLeftPart(UriPartial.Authority);
            var emailReceive  = WebConfigurationManager.AppSettings["EmailContactReceive"];
            var messageString = "<h3>" + domainName + " LIÊN HỆ</h3>";

            messageString += "<b>Họ Tên: </b>" + model.Name + "<br />";
            messageString += "<b>Email: </b>" + model.Email + "<br />";
            messageString += "<b>Điện thoại: </b>" + model.Phone + "<br />";
            messageString += "<b>Nội dung tin nhắn: </b>" + model.Message;
            var email = new MailMessage
            {
                Subject    = "Nội dung liên hệ",
                Body       = messageString,
                IsBodyHtml = true,
                To         = { emailReceive }
            };

            try
            {
                //Connect to SMTP credentials set in web.config
                var smtp = new SmtpClient();

                //Try & send the email with the SMTP settings
                smtp.Send(email);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            model.Name     = "";
            model.Email    = "";
            model.Phone    = "";
            model.Message  = "";
            model.ErrorMsg = Umbraco.GetDictionaryValue("Send.Success");
            ModelState.Clear();
            return(PartialView("~/Views/Partials/Contact/_Form.cshtml", model));
        }
Beispiel #23
0
        public ActionResult Index()
        {
            var model = GetModel <WithdrawPageViewModel>(CurrentPage);

            if (string.IsNullOrEmpty(model.Token))
            {
                return(Redirect("/?login=y"));
            }

            model.PredefinedAmounts = new string[] { };
            if (CurrentPage.HasValue("predefinedAmountsV2"))
            {
                var predefinedAmountsList = CurrentPage.Value <IEnumerable <IPublishedElement> >("predefinedAmountsV2")
                                            .Select(x => new PredefinedAmount(x));

                var customerPredefinedAmount = predefinedAmountsList.FirstOrDefault(x => x.Currency == model.CustomerSummary.CurrencyCode);
                if (customerPredefinedAmount != null)
                {
                    model.PredefinedAmounts = customerPredefinedAmount.Amounts;
                }
            }

            var isConfirmed = Request.QueryString["isConfirmed"];

            model.ShowReceipt = isConfirmed != null && Convert.ToBoolean(isConfirmed);

            if (model.ShowReceipt)
            {
                model.Receipt = new ReceiptModel
                {
                    PaymentMethod     = Umbraco.GetDictionaryValue("[Cards]CreditCard", "Credit Card"),
                    PaymentSystemName = Session["t_name"]?.ToString(),
                    Name              = model.CustomerSummary?.Username,
                    Amount            = Session["t_amount"]?.ToString(),
                    Date              = Session["t_date"]?.ToString(),
                    Status            = isConfirmed == "true" ? Umbraco.GetDictionaryValue("[Cards]Accepted", "Accepted") : Umbraco.GetDictionaryValue("[Cards]Rejects", "Rejected"),
                    TransactionNumber = Session["t_id"]?.ToString()
                };
            }



            return(CurrentTemplate(model));
        }
        /// <summary>
        /// Processes the value.
        /// </summary>
        /// <returns>
        /// The <see cref="object" /> representing the processed value.
        /// </returns>
        public override object ProcessValue()
        {
            var dictionaryKey = this.DictionaryKey
                                ?? (this.Context.PropertyInfo != null ? this.Context.PropertyInfo.Name : string.Empty);

            if (string.IsNullOrWhiteSpace(dictionaryKey))
            {
                return(null);
            }

            var content = this.Value as IPublishedContent;

            if (content == null)
            {
                return(null);
            }

            return(Umbraco.GetDictionaryValue(dictionaryKey));
        }
        public ActionResult ForgotPassword(ForgotPasswordModel model, int emailTemplateNodeId, int parentEmailTemplateNodeId)
        {
            var passMessage = Umbraco.GetDictionaryValue("UMF_PasswordResetMsg").ToString();
            var failMessage = Umbraco.GetDictionaryValue("UMF_EmailDoNotExists").ToString();

            try
            {
                var member = Members.GetByEmail(model.Email);
                if (member != null)
                {
                    //Changed form ResetPassword to GenereatePassword()
                    var mem         = umbraco.cms.businesslogic.member.Member.GetMemberFromEmail(model.Email);
                    var newpassword = System.Web.Security.Membership.GeneratePassword(4, 0);
                    mem.Password = newpassword;
                    mem.Save();

                    var parentEmailTemplate = contentService.GetById(parentEmailTemplateNodeId);
                    var fromEmail           = parentEmailTemplate.Properties["fromEmail"].Value.ToString();
                    var emailTemplate       = contentService.GetById(emailTemplateNodeId);
                    if (emailTemplate.Properties["sendToVisitor"].Value.ToString() == "1")
                    {
                        var visitorSubject = emailTemplate.Properties["subjectToVisitor"].Value.ToString();
                        var visitorMail    = emailTemplate.Properties["mailToVisitor"].Value.ToString()
                                             .Replace("#email#", model.Email).Replace("#newpassword#", newpassword);


                        var isMailSend = new SendMail().Send(fromEmail, model.Email, "", visitorSubject, visitorMail);


                        if (isMailSend)
                        {
                            return(Json(new { result = "pass", msg = passMessage }));
                        }
                    }
                }

                return(Json(new { result = "fail", msg = failMessage }));
            }
            catch (Exception ex)
            {
                return(Json(new { result = "fail", msg = failMessage }));
            }
        }
Beispiel #26
0
        //
        // GET: /BlogFollower/

        public JsonResult AddFollowers(string blogId, string userId, string cmd)
        {
            var list  = new List <BlogFollowersModel>();
            var model = new BlogFollowersModel();

            model.BlogId = int.Parse(blogId);
            model.UserId = int.Parse(userId);

            try
            {
                if (cmd == "follow")
                {
                    new BlogFollowers().Save(model);
                    model.PostAction  = "unfollow";
                    model.FeedbackMsg = Umbraco.GetDictionaryValue("UnFollowThisBlog");
                }
                else
                {
                    new BlogFollowers().Delete(model);
                    model.PostAction  = "follow";
                    model.FeedbackMsg = Umbraco.GetDictionaryValue("FollowThisBlog");
                }
                var logModel = new LogModel
                {
                    NodeId     = model.BlogId,
                    UserId     = model.UserId,
                    LogHeader  = "Blog Post",
                    LogComment = "Followed Blog",
                    TableName  = "uSomeBlogFollowers"
                };
                new LogHelper().Save(logModel);
            }
            catch (Exception ex)
            {
                model.FeedbackMsg = Umbraco.GetDictionaryValue("FollowThisBlog");
                Log.ErrorLog("Error in adding followers :: " + ex.Message);
            }


            list.Add(model);
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Beispiel #27
0
        public ActionResult Create(CreateUserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            var email          = model.Email.Trim();
            var isExistingUser = usersService.IsExistingUser(email);

            if (isExistingUser)
            {
                ModelState.AddModelError("", Umbraco.GetDictionaryValue("User Exists Message"));
                return(CurrentUmbracoPage());
            }

            var user = usersService.Create(model);

            return(RedirectToCurrentUmbracoPage());
        }
        public ActionResult HandleLoginSubmit(USNLoginFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            // Login
            if (Membership.ValidateUser(model.Username, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.Username, false);

                return(Redirect(model.ReturnUrl));
            }
            else
            {
                TempData.Add("LoginFailure", Umbraco.GetDictionaryValue("USN Login Form Login Error"));
                return(RedirectToCurrentUmbracoPage());
            }
        }
Beispiel #29
0
        public ActionResult HandleContactForm(ContactForm model)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(model.CultureLcid);
            if (!ModelState.IsValid)
            {
                model.ErrorMsg = Umbraco.GetDictionaryValue("Send.Failure");
                return(PartialView("~/Views/Partials/Contact/_Form.cshtml", model));
            }
            var emailReceive = WebConfigurationManager.AppSettings["EmailContactReceive"];

            //var domainName = Request.Url?.GetLeftPart(UriPartial.Authority);
            BackgroundJobs.SendMail.EnqueueContact("Brabantia liên hệ", emailReceive, model.Name, model.Email, model.Phone, model.Message);

            model.Name     = "";
            model.Email    = "";
            model.Phone    = "";
            model.Message  = "";
            model.ErrorMsg = Umbraco.GetDictionaryValue("Send.Success");
            ModelState.Clear();
            return(PartialView("~/Views/Partials/Contact/_Form.cshtml", model));
        }
        public ActionResult HandleForgotPassword(ForumForgotPasswordModel model)
        {
            TempData["ResetSent"] = false;
            if (!ModelState.IsValid)
            {
                return(PartialView(Umbraco.GetDictionaryValue("ForumAuthConstants.ForgotPasswordView", "Member/ForumAuth.ForgotPassword"), model));
            }

            // var membershipHelper = new MembershipHelper(UmbracoContext.Current);
            var memberService = Services.MemberService;

            // var member = membershipHelper.GetByEmail(model.EmailAddress);
            var member = memberService.GetByEmail(model.EmailAddress);

            if (member != null)
            {
                // we found a user with that email ....
                DateTime expires = DateTime.Now.AddMinutes(20);
                var      guid    = new Guid("00000000-0000-0000-0000-" + expires.ToString("ddMMyyHHmmss"));
                //00000000-0000-0000-0000-ddMMyyHHmmss
                member.SetValue(ForumAuthConstants.ResetRequestGuidPropery, guid);
                memberService.Save(member);

                // send email....
                ForumEmailHelper helper = new ForumEmailHelper();
                helper.SendResetPassword(Umbraco, member.Email, guid.ToString());

                TempData["ResetSent"] = true;
            }
            else
            {
                ModelState.AddModelError(ForumAuthConstants.ForgotPasswordKey,
                                         Umbraco.GetDictionaryValue("MemberAuth.Reset.NoUser", "No user found"));
                return(PartialView(Umbraco.GetDictionaryValue("ForumAuthConstants.ForgotPasswordView", "Member/ForumAuth.ForgotPassword")));
            }

            return(CurrentUmbracoPage());
        }