public ActionResult EmailPassword(string email) { User user = busUser.LoadUserByEmail(email); if (user == null) { // always confirm - otherwise link gets spammed ErrorDisplay.ShowMessage("We've sent password recovery info to: " + busUser.Entity.Email); } //ErrorDisplay.ShowError( // "Email address doesn't exist. Please make sure you have typed the address correctly"); else { // Always create a new random password string password = StringUtils.NewStringId(); user.Password = App.EncodePassword(password, user.Id); busUser.Save(); if (AppWebUtils.SendEmail(App.Configuration.ApplicationTitle + " Email Information", "Your CodePaste account password is: " + password + "\r\n\r\n" + "You can log on at: " + WebUtils.GetFullApplicationPath() + "\r\n\r\n" + "Please log in, view your profile and then change your password to something you can more easily remember.", busUser.Entity.Email, true)) { ErrorDisplay.ShowMessage("We've sent password recovery info to: " + busUser.Entity.Email); } else { ErrorDisplay.ShowError("Emailing of password failed."); } } return(View(ViewModel)); }
/// <summary> /// Makes user account inactive, sets a new validator /// and then emails the user. /// Assume busUser.Entity is set. /// </summary> private void SetAccountForEmailValidation() { busUser.SetUserForEmailValidation(); busUser.Save(); var msg = string.Format( @"In order to validate your email address for CodePaste.net, please click or paste the following link into your browser's address bar: {0} Once you click the link you're ready to create new code pastes with your account on the CodePaste.net site. Sincerely, The CodePaste.net Team ", WebUtils.ResolveServerUrl("~/Account/ValidateEmail/" + busUser.Entity.Validator)); AppWebUtils.SendEmail("Codepaste.net Email Validation", msg, busUser.Entity.Email, true); }