Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Simplify returnUrl handling in controllers
KrzysztofPajak7c33dd22fabf
diff --git a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs b/src/Web/Grand.Web.Admin/Controllers/HomeController.csindex bb98e4823..d45e1528c 100644--- a/src/Web/Grand.Web.Admin/Controllers/HomeController.cs+++ b/src/Web/Grand.Web.Admin/Controllers/HomeController.cs@@ -150,7 +150,7 @@ public class HomeController : BaseAdminControllerSystemCustomerFieldNames.AdminAreaStoreScopeConfiguration, "");//home page- if (string.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl))+ if (!Url.IsLocalUrl(returnUrl))returnUrl = Url.Action("Index", "Home", new { area = Constants.AreaAdmin });return Redirect(returnUrl);diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.csindex 19c4a9d0c..c975bfd11 100644--- a/src/Web/Grand.Web/Controllers/CommonController.cs+++ b/src/Web/Grand.Web/Controllers/CommonController.cs@@ -143,16 +143,12 @@ public class CommonController : BasePublicControllerpublic virtual async Task<IActionResult> SetLanguage([FromServices] AppConfig config,[FromServices] ICustomerService customerService,- string langCode, string returnUrl = default)+ string langCode, string returnUrl = ""){var language = await _languageService.GetLanguageByCode(langCode);if (!language?.Published ?? false)language = _workContext.WorkingLanguage;- //home page- if (string.IsNullOrEmpty(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");@@ -227,10 +223,6 @@ public class CommonController : BasePublicController//notificationawait _mediator.Publish(new ChangeCurrencyEvent(_workContext.CurrentCustomer, currency));- //home page- if (string.IsNullOrEmpty(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");@@ -266,10 +258,6 @@ public class CommonController : BasePublicController}}- //home page- if (string.IsNullOrEmpty(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");@@ -284,14 +272,10 @@ public class CommonController : BasePublicControllerpublic virtual async Task<IActionResult> SetTaxType([FromServices] TaxSettings taxSettings,[FromServices] ICustomerService customerService,- int customerTaxType, string returnUrl = default)+ int customerTaxType, string returnUrl = ""){var taxDisplayType = (TaxDisplayType)Enum.ToObject(typeof(TaxDisplayType), customerTaxType);- //home page- if (string.IsNullOrEmpty(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");@@ -324,10 +308,6 @@ public class CommonController : BasePublicController//notificationawait _mediator.Publish(new ChangeThemeEvent(_workContext.CurrentCustomer, themeName));- //home page- if (string.IsNullOrEmpty(returnUrl))- returnUrl = Url.RouteUrl("HomePage");-//prevent open redirection attackif (!Url.IsLocalUrl(returnUrl))returnUrl = Url.RouteUrl("HomePage");