public virtual ActionResult ForgotPasswordForm(string view = "")
 {
     var model = new ForgotPasswordModel();
     return view.IsNullOrWhiteSpace() ? PartialView(model) : PartialView(view, model);
 }
        public virtual ActionResult ForgotPassword(ForgotPasswordModel model)
        {
            if (!ModelState.IsValid) return CurrentUmbracoPage();
            var viewData = new StoreViewData();
            var member = Members.GetByUsername(model.Username);
            if (member == null)
            {
                viewData.Success = false;
                viewData.Messages = new[] { "Unknown email address." };
                ViewData["MerchelloViewData"] = viewData;
                return CurrentUmbracoPage();
            }

            var newPassword = Membership.GeneratePassword(Membership.MinRequiredPasswordLength, 0);
            var user = Membership.GetUser(model.Username);
            user.ChangePassword(newPassword, newPassword);

            // assumes you have set the SMTP settings in web.config and supplied a default "from" email
            var msg = new MailMessage
            {
                Subject = string.Format("New Password for {0}", Request.Url.Host),
                Body = string.Format("Your new password is: {0}", newPassword),
                IsBodyHtml = false
            };
            msg.To.Add(new MailAddress(model.Username));
            using (var smtpClient = new SmtpClient())
            {
                smtpClient.Send(msg);
            }

            viewData.Success = true;
            viewData.Messages = new[] { "A new password has been emailed to you." };
            ViewData["MerchelloViewData"] = viewData;
            return CurrentUmbracoPage();
        }