Exemple #1
0
        public async Task <IActionResult> OnGet([FromServices] GetProducts getProducts, bool skipCookie = false)
        {
            string urlAnterior = Request.Headers["Referer"].ToString();

            if (!(device.Type == DeviceType.Mobile || device.Type == DeviceType.Tablet))
            {
                if (!skipCookie)
                {
                    var cookieValue = _cookiesHelper.Get("PreviouslyLoggedInUser");

                    if (cookieValue != null)
                    {
                        if (cookieValue == "true")
                        {
                            return(RedirectToPage("/shop/index"));
                        }
                    }
                }
            }
            else
            {
                // Why? I don't quite understand. - Carel
                foreach (var cookie in Request.Cookies.Keys)
                {
                    if (cookie.Contains("PreviouslyLoggedInUser"))
                    {
                        Response.Cookies.Delete(cookie);
                    }
                }
            }

            Products = getProducts.Do(
                new GetProductsQuery
            {
                UserId = GetUserId()
            });

            return(Page());
        }