Ejemplo n.º 1
0
        public ActionResult ForgotPassword(string Email)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }

            try
            {
                Providers.Models.CustomMembershipUser user = Membership.GetUser(Email) as Providers.Models.CustomMembershipUser;

                if (user == null)
                {
                    ModelState.AddModelError(@"CustomMessage",
                                             @"No user was found matching that email address.");

                    return(CurrentUmbracoPage());
                }
                else
                {
                    //Create unique identifier and update db.
                    Guid resetIdentifier = _bllAccount.ResetPassword(Convert.ToInt32(user.ProviderUserKey));

                    //Send reset email to appropriate user.
                    using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient())
                    {
                        client.Send(new System.Net.Mail.MailMessage(new System.Net.Mail.MailAddress(Properties.Settings.Default.NoReplyEmail), new System.Net.Mail.MailAddress(Email))
                        {
                            Body       = $"To reset your account password, please click the following link: \n\n http://{Request.ServerVariables["HTTP_HOST"]}/umbraco/Surface/Account/ResetPassword?id={resetIdentifier.ToString()}",
                            IsBodyHtml = false,
                            Priority   = System.Net.Mail.MailPriority.High,
                            Subject    = @"Reset Your Bundled Broker Account Password",
                        });
                    }
                }

                //Return success message.
                AlertSuccess($"Please check {Email} for password reset instructions.");
                return(CurrentUmbracoPage());
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(@"CustomMessage",
                                         $"We are experiencing technical difficulties Please try again later\n{ex.Message}");

                return(CurrentUmbracoPage());
            }
        }
Ejemplo n.º 2
0
        public ActionResult Manage(Providers.Models.CustomMembershipUser model)
        {
            if (!ModelState.IsValid)
            {
                return(CurrentUmbracoPage());
            }
            else
            {
                try
                {
                    if (User.Identity.IsAuthenticated)
                    {
                        Membership.UpdateUser(model);
                    }
                    else
                    {
                        int userId = _bllAccount.CreateUser(model.Email, model.Phone, model.FirstName, model.LastName);

                        MembershipCreateStatus creationStatus;

                        MembershipUser user = Membership.CreateUser(model.Email, model.Password1, model.Email, null, null,
                                                                    true, userId, out creationStatus);

                        if (creationStatus == MembershipCreateStatus.Success)
                        {
                            Roles.AddUserToRole(model.Email, "User");

                            AlertSuccess("Account successfully created.");
                        }
                        else
                        {
                            AlertWarning("Account could not be created.");
                        }
                    }

                    AlertSuccess("Account sucessfully updated.");

                    return(RedirectToCurrentUmbracoPage());
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(@"CustomMessage",
                                             $"We are experiencing technical difficulties Please try again later\n{ex.Message}");

                    return(RedirectToCurrentUmbracoPage());
                }
            }
        }
Ejemplo n.º 3
0
 public ActionResult ManageGeneral(Providers.Models.CustomMembershipUser model)
 {
     return(PartialView(@"~/Views/Partials/Account/ManageGeneral.cshtml", model));
 }