diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 48da471530ad..cb6ff8065688 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -4,7 +4,9 @@ class RegistrationsController < Devise::RegistrationsController def new return redirect_to root_path(signin: "true") if user_signed_in? - if URI(request.referer || "").host == URI(request.base_url).host + if URI(request.referer || "").host == URI(request.base_url).host && + URI(request.referer).path.exclude?("/enter") && + URI(request.referer).path.exclude?("/users/sign_up") store_location_for(:user, request.referer) end @@ -32,13 +34,22 @@ def create redirect_to confirm_email_path(email: resource.email) else sign_in(resource) - redirect_to root_path + respond_with resource, location: after_sign_up_path_for(resource) end else render action: "by_email" end end + def after_sign_up_path_for(resource) + referrer = stored_location_for(resource) || root_path + if referrer + onboarding_path(referrer: referrer) + else + onboarding_path + end + end + private def prepare_new_forem_instance diff --git a/app/javascript/onboarding/Onboarding.jsx b/app/javascript/onboarding/Onboarding.jsx index 573b48396bca..7f86e4f22f5a 100644 --- a/app/javascript/onboarding/Onboarding.jsx +++ b/app/javascript/onboarding/Onboarding.jsx @@ -17,6 +17,8 @@ export class Onboarding extends Component { this.nextSlide = this.nextSlide.bind(this); this.prevSlide = this.prevSlide.bind(this); this.slidesCount = slides.length; + const url = new URL(window.location); + this.previousLocation = url.searchParams.get('referrer'); this.state = { currentSlide: 0, @@ -49,7 +51,7 @@ export class Onboarding extends Component { window.location.href = '/'; } } else { - window.location.href = '/'; + window.location.href = this.previousLocation || '/'; } } @@ -68,7 +70,7 @@ export class Onboarding extends Component { return; } const dataBody = JSON.parse(localStorage.getItem('last_interacted_billboard')); - + if (dataBody && dataBody['billboard_event']) { dataBody['billboard_event']['category'] = 'signup'; @@ -96,7 +98,7 @@ export class Onboarding extends Component { communityConfig.communityBackgroundColor && communityConfig.communityBackgroundColor2 ? { - background: `linear-gradient(${communityConfig.communityBackgroundColor}, + background: `linear-gradient(${communityConfig.communityBackgroundColor}, ${communityConfig.communityBackgroundColor2})`, } : { top: 777 }