Fix: Redirect to portal with default locale (#5467)

- Redirect to default locale if URL does not provide the locale param
This commit is contained in:
Tejaswini Chile
2022-09-20 23:01:39 +05:30
committed by GitHub
parent d28502b917
commit c556e9c694
3 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
class Public::Api::V1::PortalsController < PublicController
before_action :ensure_custom_domain_request, only: [:show]
before_action :redirect_to_portal_with_locale, only: [:show]
before_action :portal
layout 'portal'
@@ -9,5 +10,12 @@ class Public::Api::V1::PortalsController < PublicController
def portal
@portal ||= Portal.find_by!(slug: params[:slug], archived: false)
@locale = params[:locale] || @portal.default_locale
end
def redirect_to_portal_with_locale
return if params[:locale].present?
redirect_to "/hc/#{@portal.slug}/#{@portal.default_locale}"
end
end