Пример #1
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.");
            }
        }
Пример #2
0
        /// <summary>
        /// Executes the specified formid.
        /// </summary>
        /// <param name="formid">The formid.</param>
        /// <param name="fields">The fields.</param>
        /// <param name="data">The data.</param>
        public override void Execute(ID formid, AdaptedResultList fields, object[] data)
        {
            AnalyticsUtil.AuthentificationClickedLoginButton();

            base.Execute(formid, fields, data);
        }