1
0
Fork 0

Add redirect on signup for approved users

Dieser Commit ist enthalten in:
Angus McLeod 2018-06-05 12:25:44 +10:00
Ursprung a5a18666ad
Commit 17ba9976c0

Datei anzeigen

@ -88,11 +88,10 @@ after_initialize do
if Wizard.user_requires_completion?(@user) if Wizard.user_requires_completion?(@user)
wizard_id = $redis.get('custom_wizard_redirect') wizard_id = $redis.get('custom_wizard_redirect')
unless url === '/' if wizard_id && url != '/'
CustomWizard::Wizard.set_redirect(@user, wizard_id, url) CustomWizard::Wizard.set_redirect(@user, wizard_id, url)
url = "/w/#{wizard_id.dasherize}"
end end
url = "/w/#{wizard_id.dasherize}"
end end
super(url) super(url)
end end
@ -116,8 +115,11 @@ after_initialize do
@excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/'] @excluded_routes ||= SiteSetting.wizard_redirect_exclude_paths.split('|') + ['/w/']
url = request.referer || request.original_url url = request.referer || request.original_url
if @wizard_id && request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url } if request.format === 'text/html' && !@excluded_routes.any? { |str| /#{str}/ =~ url } && @wizard_id
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer) if request.referer !~ /\/w\// if request.referer !~ /\/w\// && request.referer !~ /\/invites\//
CustomWizard::Wizard.set_redirect(current_user, @wizard_id, request.referer)
end
redirect_to "/w/#{@wizard_id.dasherize}" redirect_to "/w/#{@wizard_id.dasherize}"
end end
end end
@ -144,5 +146,12 @@ after_initialize do
end end
end end
DiscourseEvent.on(:user_approved) do |user|
if wizard_id = CustomWizard::Wizard.after_signup
user.custom_fields['redirect_to_wizard'] = wizard_id
user.save_custom_fields(true)
end
end
DiscourseEvent.trigger(:custom_wizard_ready) DiscourseEvent.trigger(:custom_wizard_ready)
end end