protected void btnChangePassword_Click(object sender, EventArgs e)
{
string UserName = HttpContext.Current.User.Identity.Name;
DotNetNuke.Entities.Users.UserInfo userInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(PortalId, UserName);
DotNetNuke.Security.Membership.MembershipProvider membershipProvider = DotNetNuke.Security.Membership.MembershipProvider.Instance();
if (membershipProvider.PasswordFormat == DotNetNuke.Security.Membership.PasswordFormat.Encrypted)
{
string oldPassword = DotNetNuke.Entities.Users.UserController.GetPassword(ref userInfo, userInfo.Membership.PasswordAnswer);
if (oldPassword == txtOldPassword.Text)
{
string newPassword = txtNewPassword.Text.Trim();//DotNetNuke.Entities.Users.UserController.GeneratePassword(membershipProvider.MinPasswordLength);
DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, newPassword);
txtOldPassword.Text = "";
txtNewPassword.Text = "";
txtOldPassword.Focus();
lblmsg.Text = "Password changed successfully.";
}
else
{
lblmsg.Text = "OldPassword did not match.";
}
}
}