Beispiel #1
0
        /// <summary>
        /// Handles the Clicked event of the ProceedToCheckout control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The arguments.</param>
        protected void ProceedToCheckoutClicked(object sender, EventArgs args)
        {
            string checkoutPath = ItemUtil.GetNavigationLinkPath("CheckOut");

            if (!string.IsNullOrEmpty(checkoutPath))
            {
                Response.Redirect(checkoutPath);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Redirects to the login menu if the user exists.
        /// Otherwise returns an error message / exception.
        /// </summary>
        /// <param name="formid"> The formid. </param>
        /// <param name="fields"> The fields. </param>
        /// <exception cref="ValidatorException">Username or password was wrong. Please try again.</exception>
        protected override void CreateItemByFields(ID formid, AdaptedResultList fields)
        {
            AnalyticsUtil.AuthentificationClickedLoginButton();

            NameValueCollection form = new NameValueCollection();

            ActionHelper.FillFormData(form, fields, null);

            ICustomerManager <CustomerInfo> customerManager = Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            if (Sitecore.Context.User.IsAuthenticated)
            {
                AuthenticationManager.Logout();
                customerManager.ResetCurrentUser();
            }

            string fullNickName = Sitecore.Context.Domain.GetFullName(form["UserName"]);
            bool   loginResult  = customerManager.LogInCustomer(fullNickName, form["Password"]);

            if (loginResult)
            {
                AnalyticsUtil.AuthentificationUserLoginSucceeded(fullNickName);

                try
                {
                    string loginPath = ItemUtil.GetNavigationLinkPath("Login");
                    if (!string.IsNullOrEmpty(loginPath))
                    {
                        HttpContext.Current.Response.Redirect(loginPath);
                    }
                    else
                    {
                        if (HttpContext.Current.Request.UrlReferrer != null)
                        {
                            HttpContext.Current.Response.Redirect(HttpContext.Current.Request.UrlReferrer.AbsolutePath);
                        }
                    }
                }
                catch (NavigateLinkNotFoundException)
                {
                    HttpContext.Current.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
                }
            }
            else
            {
                AnalyticsUtil.AuthentificationUserLoginFailed(fullNickName);
                throw new ValidatorException("Username or password was wrong. Please try again.");
            }
        }