+1-888-365-2779
Try Now
More in this section

Forums / Security / Reset passowrd email

Reset passowrd email

2 posts, 0 answered
  1. Adam
    Adam avatar
    33 posts
    Registered:
    23 Feb 2009
    25 Nov 2009
    Link to this post
    Are users supposed to be sent an email when thieir password is reset in the CMS?


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    26 Nov 2009
    Link to this post
    Hi Adam,

    There is no built in functionality for sending emails when you reset the password from the backend. You can modify Sitefinity/Admin/CmsAdmin/Users.aspx.cs and subscribe for Button.Click event of the reset button as shown below:

    protected void passwordRecoveryButton_Click(object sender, EventArgs e)
      {
          string newPassword = manageUsers.Manager.MembershipProvider.ResetPassword(manageUsers.UserName, "42");
          Telerik.Security.WebControls.ManageUsers.EditContainer editContainer = manageUsers.GetCurrentContainer() as Telerik.Security.WebControls.ManageUsers.EditContainer;
          if (editContainer != null)
          {
              Control passRecovery = editContainer.FindControl("passwordRecoveryButton");
              if (passRecovery != null)
              {
                  int index = editContainer.Controls.IndexOf(passRecovery);
     
                  Literal newPass = new Literal();
                  newPass.Text = "New password: ";
     
                  Label newNote = new Label();
                  newNote.Controls.Add(newPass);
                  Literal passLiteral = new Literal();
                  passLiteral.Text = newPassword;
                  HtmlGenericControl strong = new HtmlGenericControl("strong");
                  strong.Controls.Add(passLiteral);
     
                  newNote.Controls.Add(strong);
     
                  editContainer.Controls.AddAt(index + 1, newNote);
                  string senderMail = "senderMailhere"
                  string userName = manageUsers.UserName;
                  MembershipUser user = Membership.GetUser(userName);
                  MailMessage message = new MailMessage(senderMail, user.Email);
                  message.Body = newPass.Text + passLiteral.Text;
                  SmtpClient client = new SmtpClient();
                  client.Send(message);
     
              }
          }

    By doing so you will be able to send email to the user which password is reset. The email body will contain the new password.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered