Пример #1
0
    /// <summary>
    /// Saves password to existing user and sends notification email.
    /// </summary>
    /// <param name="informationMessage">Message to be displayed in password has been successfully changed.</param>
    /// <param name="password">If is not given, a new password will be generated.</param>
    private void SavePassword(string informationMessage, string password = null)
    {
        var user = Customer.CustomerUser;

        if (user == null)
        {
            return;
        }

        if (String.IsNullOrEmpty(password))
        {
            password = UserInfoProvider.GenerateNewPassword(SiteContext.CurrentSiteName);
        }

        UserInfoProvider.SetPassword(user, password, true);

        if (!CustomerInfoProvider.SendLoginDetailsNotificationEmail(user, password, TEMPLATE_PASSWORD_CHANGED, SiteContext.CurrentSiteID))
        {
            ShowConfirmation(informationMessage);
            ShowError(GetString("com.customer.notificationemailnotsent"));
        }
        else
        {
            ShowConfirmation(informationMessage + " " + GetString("com.customer.notificationsent"));
        }
    }