Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 20:02:54 +01:00
Ensure redirects are dasherized at the point of routing.
Dieser Commit ist enthalten in:
Ursprung
cf4beb7619
Commit
4f4b8c49b2
1 geänderte Dateien mit 8 neuen und 5 gelöschten Zeilen
13
plugin.rb
13
plugin.rb
|
@ -76,7 +76,7 @@ after_initialize do
|
||||||
::UsersController.class_eval do
|
::UsersController.class_eval do
|
||||||
def wizard_path
|
def wizard_path
|
||||||
if custom_wizard_redirect = $redis.get('custom_wizard_redirect')
|
if custom_wizard_redirect = $redis.get('custom_wizard_redirect')
|
||||||
"#{Discourse.base_url}/w/#{custom_wizard_redirect}"
|
"#{Discourse.base_url}/w/#{custom_wizard_redirect.dasherize}"
|
||||||
else
|
else
|
||||||
"#{Discourse.base_url}/wizard"
|
"#{Discourse.base_url}/wizard"
|
||||||
end
|
end
|
||||||
|
@ -92,7 +92,7 @@ after_initialize do
|
||||||
CustomWizard::Wizard.set_redirect(@user, wizard_id, url)
|
CustomWizard::Wizard.set_redirect(@user, wizard_id, url)
|
||||||
end
|
end
|
||||||
|
|
||||||
url = "/w/#{wizard_id}"
|
url = "/w/#{wizard_id.dasherize}"
|
||||||
end
|
end
|
||||||
super(url)
|
super(url)
|
||||||
end
|
end
|
||||||
|
@ -113,9 +113,12 @@ after_initialize do
|
||||||
|
|
||||||
def redirect_to_wizard_if_required
|
def redirect_to_wizard_if_required
|
||||||
@wizard_id ||= current_user.custom_fields['redirect_to_wizard']
|
@wizard_id ||= current_user.custom_fields['redirect_to_wizard']
|
||||||
if @wizard_id && request.referer !~ /w/ && request.referer !~ /admin/
|
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
|
||||||
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer)
|
url = request.referer || request.original_url
|
||||||
redirect_to "/w/#{@wizard_id}"
|
|
||||||
|
if @wizard_id && request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url }
|
||||||
|
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer) if request.referer !~ /\/w\//
|
||||||
|
redirect_to "/w/#{@wizard_id.dasherize}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Laden …
In neuem Issue referenzieren