Ejemplo n.º 1
0
        /// <summary>
        /// Handles the OnClick event of the btnLogOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogOut_OnClick(object sender, EventArgs e)
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();

            var url = string.Empty;

            try
            {
                if (Sitecore.Context.Item.Security.CanRead(Sitecore.Security.Accounts.User.Current))
                {
                    var qs = WebUtil.GetQueryString();

                    Item catalogItem = null;

                    using (new SecurityDisabler())
                    {
                        catalogItem = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>().ProductCatalogItem;
                    }

                    if (catalogItem == null)
                    {
                        url = LinkManager.GetItemUrl(Sitecore.Context.Item);
                    }
                    else
                    {
                        url = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>().GetVirtualProductUrl(catalogItem, Sitecore.Context.Item);
                    }

                    qs  = qs.TrimStart('?');
                    qs  = (qs != string.Empty) ? "?" + qs : string.Empty;
                    url = string.Concat(url, qs);
                }
                else
                {
                    url = "/";
                }
            }
            catch (Exception err)
            {
                Log.Warn(err.Message, err);
            }

            this.Response.Redirect(url);
        }
Ejemplo n.º 2
0
        public void LogOutCurrentUser()
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            try
            {
                Tracker.StartTracking();
                AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);
            }
            catch (Exception ex)
            {
                LogException(ex);
            }

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the OnClick event of the btnLogOut control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnLogOut_OnClick(object sender, EventArgs e)
        {
            ICustomerManager <CustomerInfo> customerManager = Sitecore.Ecommerce.Context.Entity.Resolve <ICustomerManager <CustomerInfo> >();

            AnalyticsUtil.AuthentificationUserLoggedOut(customerManager.CurrentUser.NickName);

            AuthenticationManager.Logout();

            customerManager.ResetCurrentUser();

            var url = string.Empty;

            if (Sitecore.Context.Item.Security.CanRead(User.Current))
            {
                var qs = WebUtil.GetQueryString();

                var itemUrl = Sitecore.Context.ClientData.GetValue("itempath") as string;
                if (string.IsNullOrEmpty(itemUrl))
                {
                    url = LinkManager.GetItemUrl(Sitecore.Context.Item);
                }
                else
                {
                    VirtualProductResolver virtualProductResolver = Sitecore.Ecommerce.Context.Entity.Resolve <VirtualProductResolver>();
                    var folderItem = virtualProductResolver.ProductCatalogItem;
                    if (folderItem != null)
                    {
                        url = virtualProductResolver.GetVirtualProductUrl(folderItem, Sitecore.Context.Item);
                    }
                }

                qs  = qs.TrimStart('?');
                qs  = (qs != string.Empty) ? "?" + qs : string.Empty;
                url = string.Concat(url, qs);
            }
            else
            {
                url = "/";
            }

            Response.Redirect(url);
        }