Hi all!
I've been searching around for some code examples on how to reset a password for a user within a custom module, and have come up with nothing. I have code that creates users, edits user info and profile info, creates the initial password, etc.. However, I can't find a way to change a user password as you can in the 'manage password' dnn menu. I'm using DNN 4.7 (or was it 4.6..., if it matters I'll find out for sure)
Here's the code I'm using that doesn't work (though it doesn't return false as I'd expect):
string oldPassword = DotNetNuke.Entities.Users.UserController.ResetPassword(userInfo, "");
if (!DotNetNuke.Entities.Users.UserController.ChangePassword(userInfo, oldPassword, password))
{
OnError("There was an error changing the password!");
}
As you can see, I'm trying to get the old password by using ResetPassword on the userInfo. The next line doesn't appear to work, however (though it returns true....)
Currently I have a filled UserInfo object of the user whose password I'm trying to reset, but I don't have their actual password. I have a routine that generates a random password, or alternatively I'd like the user of my module to be able to type in a temporary password that the user must reset when they log in. If someone can provide me with the code, or the function that I'll need to use, I'd be appreciative. Thanks!
PS. How do I correctly submit formatted code on this form? I don't see a button or explaination, though I could be blind as a bat! Thanks!