To be able to inform a user about it's newly created account, and provide the users it's password I thought of the following construction, which sets a new password which I afterwards send by e-mail. However.. one problem! The password never gets updated.. it stays the initally password set by the umbraco dialog.
I use this code:
Member.New += new Member.NewEventHandler(Member_AfterNew);
Did you check on the return value of the call to ResetPassword and ChangePassword? Maybe your declaration of the Membership Provider in the web.config does not allow password reset? You could check this by putting a test on the Membership.EnablePasswordReset property. More info about this can be found in the example on the Microsoft site: http://msdn.microsoft.com/en-us/library/d94bdzz2.aspx
Reset password after creating new user
To be able to inform a user about it's newly created account, and provide the users it's password I thought of the following construction, which sets a new password which I afterwards send by e-mail. However.. one problem! The password never gets updated.. it stays the initally password set by the umbraco dialog.
I use this code:
Member.New += new Member.NewEventHandler(Member_AfterNew);
void Member_AfterNew(Member sender, NewEventArgs e)
{
String userName = sender.LoginName;
String newPassword = Membership.GeneratePassword(7,2);
MembershipUser user = Membership.GetUser(userName);
user.ChangePassword(user.ResetPassword(), newPassword);
// ... send by email the newPassword
}
What could possibly go wrong?
That's strange, this is exactly what I do and it works here. (I guess you got this from the documentation I wrote)
Do you still have this problem?
Hi Mathijs,
Did you check on the return value of the call to ResetPassword and ChangePassword? Maybe your declaration of the Membership Provider in the web.config does not allow password reset? You could check this by putting a test on the Membership.EnablePasswordReset property. More info about this can be found in the example on the Microsoft site: http://msdn.microsoft.com/en-us/library/d94bdzz2.aspx
Cheers,
Michael.
Thanks for you replies guys. Problem remains. My web config look like this:
<add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Hashed" />
So the PasswordReset is enabled.
I did the following trials to change codes behaviour:
is working on a reply...