diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0e0c27e..4cbd47c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,7 +38,7 @@ def after_sign_in_path_for(resource) unless redirect_club_id.nil? then club = Club.find_by_id(redirect_club_id) session[:redirect_club_id] = nil - current_user.post_sign_in_clubsite_redirect_for_club(club, session) + clubsite_path(club) else session[:previous_url] || root_path end diff --git a/app/controllers/clubs_controller.rb b/app/controllers/clubs_controller.rb index cf8298d..5c08575 100644 --- a/app/controllers/clubs_controller.rb +++ b/app/controllers/clubs_controller.rb @@ -6,6 +6,24 @@ def index end end + def show_clubsite + club = Club.find_by_id(params[:club_id]) + if current_user.nil? + url = club.clubsite_url('/') + else + cross_session = CrossAppSession.find_by cross_app_session_id: session[:cross_app_session_id] + # If we don't have a cross app session yet, create it. + if cross_session.nil? + cross_session = CrossAppSession.new_for_user(current_user) + session[:cross_app_session_id] = cross_session.cross_app_session_id + cross_session.save + end + url = club.clubsite_url("/users/localLogin?cross_app_session_id=" + cross_session.cross_app_session_id) + end + + redirect_to url, allow_other_host: true + end + # provides a CSV file with participant counts for the club events and any child club events def participant_counts respond_to do |format| diff --git a/app/controllers/short_links_controller.rb b/app/controllers/short_links_controller.rb index ac7eb57..cc3ef84 100644 --- a/app/controllers/short_links_controller.rb +++ b/app/controllers/short_links_controller.rb @@ -1,6 +1,6 @@ class ShortLinksController < ApplicationController def show link = ShortLink.find_by!(name: params[:name]) - redirect_to link.destination, status: :moved_permanently + redirect_to link.destination, status: :moved_permanently, allow_other_host: true end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fdd5c7d..9fe2561 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -35,7 +35,7 @@ def send_message def sign_in_clubsite if user_signed_in? club = Club.find_by_id(params[:redirect_club_id]) - redirect_to(current_user.post_sign_in_clubsite_redirect_for_club(club, session)) + redirect_to(clubsite_url(club)) session[:redirect_club_id] = nil else session[:redirect_club_id] = params[:redirect_club_id] diff --git a/app/models/user.rb b/app/models/user.rb index a30b847..780e72f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -59,18 +59,6 @@ def self.find_all_real User.where('users.email IS NOT NULL') end - # Helpers - def post_sign_in_clubsite_redirect_for_club(club, session) - cross_session = CrossAppSession.find_by cross_app_session_id: session[:cross_app_session_id] - # If we don't have a cross app session yet, create it. - if cross_session.nil? - cross_session = CrossAppSession.new_for_user(self) - session[:cross_app_session_id] = cross_session.cross_app_session_id - cross_session.save - end - club.clubsite_url("/users/localLogin?cross_app_session_id=" + cross_session.cross_app_session_id) - end - def first_name names = name.split if names.length == 1 diff --git a/config/routes.rb b/config/routes.rb index eb2d744..5221868 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,7 @@ get 'events', to: 'events#index', format: true get 'club/:club_id/events', to: 'events#index', format: true get 'club/:club_id/participation_report', to: 'clubs#participant_counts' + get 'clubsite/:club_id', to: 'clubs#show_clubsite', as: :clubsite get 'api/maps', to: 'maps#index'