Skip to main content
Code Review

Return to Revisions

2 of 2
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/

Something like this? The booleans are there so you can warn the user if you didn't send an email. That said, I agree with SilverlightFox's answer; allowing users to reset each other's passwords is probably a bad idea.

private bool SendNewPasswordToUserByEmail(string email)
{
 return SendNewPasswordToUser(Membership.GetUserNameByEmail(email ?? String.Empty));
}
private bool SendNewPasswordToUser(string userName)
{
 MembershipUser mu = Membership.GetUser(userName ?? String.Empty);
 if (mu == null)
 {
 return false;
 }
 string password = mu.ResetPassword();
 EmailPassword(password, mu.Email);
 return true;
}

Personally, I'd add another if to check for null rather than using ??, but you said to reduce use of conditionals.

Brian
  • 548
  • 3
  • 18
default

AltStyle によって変換されたページ (->オリジナル) /