diff --git a/app/views/impersonation_sessions/_super_admin_bar.html.erb b/app/views/impersonation_sessions/_super_admin_bar.html.erb index fddb270b..401a5a86 100644 --- a/app/views/impersonation_sessions/_super_admin_bar.html.erb +++ b/app/views/impersonation_sessions/_super_admin_bar.html.erb @@ -3,6 +3,10 @@ <%= lucide_icon "alert-triangle", class: "w-6 h-6 text-white mr-2" %> Super Admin +
+ <%= link_to "Jobs", good_job_url, class: "text-white underline hover:text-gray-100" %> +
+
<% if Current.session.active_impersonator_session.present? %>
diff --git a/config/initializers/good_job.rb b/config/initializers/good_job.rb index 9841d0e9..c3794ad6 100644 --- a/config/initializers/good_job.rb +++ b/config/initializers/good_job.rb @@ -10,4 +10,16 @@ Rails.application.configure do } } end + + # Auth for jobs admin dashboard + ActiveSupport.on_load(:good_job_application_controller) do + before_action do + raise ActionController::RoutingError.new("Not Found") unless current_user&.super_admin? + end + + def current_user + session = Session.find_by(id: cookies.signed[:session_token]) + session&.user + end + end end diff --git a/config/routes.rb b/config/routes.rb index 230d7743..978e349a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + mount GoodJob::Engine => "good_job" + get "changelog", to: "pages#changelog" get "feedback", to: "pages#feedback" get "early-access", to: "pages#early_access" diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index 7e643945..a7c04b5c 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -31,4 +31,15 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest assert_redirected_to new_session_path assert_equal "You have signed out successfully.", flash[:notice] end + + test "super admins can access the jobs page" do + sign_in users(:maybe_support_staff) + get good_job_url + assert_redirected_to "http://www.example.com/good_job/jobs?locale=en" + end + + test "non-super admins cannot access the jobs page" do + get good_job_url + assert_response :not_found + end end