public bool ChangePasswordEmail(string emailAddress, string baseSiteUrl, string productName, BOEmailConfig email) { try { MembershipUser membershipUser = VerifyUser(emailAddress); if (membershipUser != null) { string temporaryPassword = BOUser.GenerateRandomPassword(); if (membershipUser.ChangePassword(membershipUser.ResetPassword(), temporaryPassword)) { StringBuilder strBody = new StringBuilder(); string emailTemplate = GetEmailTemplate(SettingKeys.SystemSecurity.EmailVerificationTemplate); strBody.Append(emailTemplate); strBody = strBody.Replace("[username]", membershipUser.UserName); strBody = strBody.Replace("[link]", baseSiteUrl + "/Account/ResetPassword/" + membershipUser.ProviderUserKey.ToString()); strBody = strBody.Replace("[Product/Website]", productName); return email.SendEmail(emailAddress, "", "", "Change Password Request", strBody.ToString(), true); } return false; } } catch (Exception ex) { logger.ErrorException("error occurs during change password verification :-", ex); return false; } return false; }
public bool ForgotUserNameEmail(string emailAddress, string baseUrl, string productName, BOEmailConfig email) { try { MembershipUser membershipUser = VerifyUser(emailAddress); if (membershipUser != null) { StringBuilder strBody = new StringBuilder(); string emailTemplate = GetEmailTemplate(SettingKeys.SystemSecurity.ForgotUserNameTemplate); strBody.Append(emailTemplate); strBody = strBody.Replace("[username]", membershipUser.UserName.ToString()); strBody = strBody.Replace("[link]", baseUrl + "/Account/LogOn"); strBody = strBody.Replace("[Product/Website]", productName); email.SendEmail(emailAddress, "", "", "Forgot User Name Request", strBody.ToString(), true); return true; } } catch (Exception ex) { logger.ErrorException("error occurs during forgot user name verification :-", ex); } return false; }
public ForgotPasswordEmailResult ForgotPasswordEmail(string emailAddress, string baseSiteUrl, string productName, BOEmailConfig email) { try { MembershipUser membershipUser = VerifyUser(emailAddress); if (membershipUser != null) { string temporaryPassword = BOUser.GenerateRandomPassword(); membershipUser.ChangePassword(membershipUser.ResetPassword(), temporaryPassword); BOUser user = _userService.GetByGUID(membershipUser.ProviderUserKey.ToString()); user.IsTemporaryPassword = true; _userRepository.Save(user); StringBuilder strBody = new StringBuilder(); string emailTemplate = GetEmailTemplate(SettingKeys.SystemSecurity.ForgotPasswordEmailTemplate); strBody.Append(emailTemplate); strBody = strBody.Replace("[username]", membershipUser.UserName.ToString()); strBody = strBody.Replace("[link]", baseSiteUrl + "/Account/LogOn"); strBody = strBody.Replace("[Product/Website]", productName); strBody = strBody.Replace("[password]", temporaryPassword); email.SendEmail(membershipUser.Email, "", "", "Forgot Password Request", strBody.ToString(), true); if (_settingService.GetSetting<bool>(SettingKeys.SystemSecurity.ForgotPasswordEmailTemporaryPassword)) return ForgotPasswordEmailResult.TemporaryPasswordSent; else return ForgotPasswordEmailResult.EmailVerificationSent; } } catch (Exception ex) { logger.ErrorException("error occurs during forgot password verification :-", ex); } return ForgotPasswordEmailResult.Failed; }