Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Security > Reset passowrd email

Reset passowrd email

  • Adam avatar

    Posted on Nov 25, 2009 (permalink)

    Are users supposed to be sent an email when thieir password is reset in the CMS?


    Reply

  • Ivan Dimitrov Ivan Dimitrov admin's avatar

    Posted on Nov 26, 2009 (permalink)

    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.

    Reply

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Security > Reset passowrd email