private bool HandleAutoRegistration(ShoppingCartInfo currentShoppingCart)
    {
        registrationBanned = string.Empty;
        var customer = currentShoppingCart.Customer;

        if ((customer == null) || customer.CustomerIsRegistered)
        {
            return(true);
        }

        if (ECommerceSettings.AutomaticCustomerRegistration(currentShoppingCart.ShoppingCartSiteID) || currentShoppingCart.RegisterAfterCheckout)
        {
            // Ban IP addresses which are blocked for registration
            var registrationBan  = !BannedIPInfoProvider.IsAllowed(currentShoppingCart.SiteName, BanControlEnum.Registration);
            var allUserActionBan = !BannedIPInfoProvider.IsAllowed(currentShoppingCart.SiteName, BanControlEnum.AllNonComplete);

            if (registrationBan || allUserActionBan)
            {
                registrationBanned = GetString("banip.ipisbannedregistration");
                LogError(registrationBanned, EVENT_CODE_VALIDATION);
                return(false);
            }
            // Auto-register user and send mail notification
            CustomerInfoProvider.RegisterAndNotify(customer, currentShoppingCart.RegisterAfterCheckoutTemplate);
        }

        return(true);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Registers new user with generated password.
    /// </summary>
    private void RegisterCustomer()
    {
        var password = UserInfoProvider.GenerateNewPassword(SiteContext.CurrentSiteName);

        var userNotUniqueError = ValidateUserUniqueness();

        if (!String.IsNullOrEmpty(userNotUniqueError))
        {
            ShowError(userNotUniqueError);
            return;
        }

        var displayError = false;

        if (!CustomerInfoProvider.RegisterAndNotify(Customer, TEMPLATE_REGISTER_AND_NOTIFY, Customer.CustomerEmail, password))
        {
            if (Customer.CustomerUserID <= 1)
            {
                ShowError(GetString("com.customer.usernotcreated"));
                return;
            }

            displayError = true;
        }

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "LoginRedirect", "parent.window.location='" + GetRedirectUrl(displayError) + "';", true);
    }
    protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
    {
        CheckModifyPermissions();

        switch (e.CommandName)
        {
        // Registering user with random password
        case "create":
        {
            var errorMessage = ValidateForm();
            if (!String.IsNullOrEmpty(ValidateForm()))
            {
                ShowError(errorMessage);
                return;
            }

            var displayError = false;
            if (!CustomerInfoProvider.RegisterAndNotify(Customer, TEMPLATE_REGISTER_AND_NOTIFY, Customer.CustomerEmail, PasswordField))
            {
                if (Customer.CustomerUserID <= 1)
                {
                    ShowError(GetString("com.customer.usernotcreated"));
                    return;
                }

                displayError = true;
            }

            ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "LoginRedirect", "parent.window.location='" + GetRedirectUrl(displayError) + "';", true);
        }

        break;

        // Changing password to registered customer
        case ComponentEvents.SAVE:
        {
            var errorMessage = ValidateForm();
            if (!String.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
                return;
            }

            SavePassword(GetString("com.customer.passwordsaved"), PasswordField);

            break;
        }

        // Generate new random password and send it to customer
        case "generate":
            SavePassword(GetString("com.customer.passwordgenerated"));

            break;
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Process form data.
    /// </summary>
    public override bool ProcessStep()
    {
        int customerId = 0;

        if (ExistingCustomer)
        {
            // Select an existing customer
            customerId = customerSelector.CustomerID;
        }

        if (!ExistingCustomer)
        {
            // Check permissions
            if (!HasModifyCustomerPermission)
            {
                RedirectToAccessDenied("CMS.Ecommerce", "ModifyCustomers OR EcommerceModify");
                return(false);
            }

            // Create a new customer
            customerForm.SaveData(null, false);

            var customer = (CustomerInfo)EditedObject;
            customerId = customer.CustomerID;

            var reg = ValidationHelper.GetBoolean(customerForm.GetFieldValue("Register"), false);
            if (reg)
            {
                CustomerInfoProvider.RegisterAndNotify(customer, "Ecommerce.AutomaticRegistration");
            }
        }

        // Assign customer and user to the shopping cart
        if (customerId > 0)
        {
            var customer = CustomerInfoProvider.GetCustomerInfo(customerId);

            if (customer != null)
            {
                ShoppingCart.ShoppingCartCustomerID = customerId;

                if (customer.CustomerIsRegistered)
                {
                    ShoppingCart.User = UserInfoProvider.GetUserInfo(customer.CustomerUserID) ?? AuthenticationHelper.GlobalPublicUser;
                }

                return(true);
            }
        }

        return(false);
    }
    /// <summary>
    /// Process form data.
    /// </summary>
    public override bool ProcessStep()
    {
        int customerId = 0;

        if (ExistingCustomer)
        {
            // Select an existing customer
            customerId = customerSelector.CustomerID;
        }

        if (!ExistingCustomer)
        {
            // Check permissions
            if (!HasModifyCustomerPermission)
            {
                RedirectToAccessDenied(ModuleName.ECOMMERCE, "ModifyCustomers OR EcommerceModify");
                return(false);
            }

            // Create a new customer
            customerForm.SaveData(null, false);

            var customer = (CustomerInfo)EditedObject;
            customerId = customer.CustomerID;

            var reg = ValidationHelper.GetBoolean(customerForm.GetFieldValue("Register"), false);
            if (reg)
            {
                CustomerInfoProvider.RegisterAndNotify(customer, "Ecommerce.AutomaticRegistration");
            }
        }

        // Assign customer and user to the shopping cart
        ShoppingCart.SetShoppingCartUser(customerId);

        return(customerId > 0);
    }