Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.

Commit b611dfd

Browse files
authored
Add back good job dashboard with auth (#1364)
1 parent ba49fea commit b611dfd

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

app/views/impersonation_sessions/_super_admin_bar.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
<%= lucide_icon "alert-triangle", class: "w-6 h-6 text-white mr-2" %>
44
<span class="text-white font-semibold uppercase">Super Admin</span>
55
</div>
6+
<div>
7+
<%= link_to "Jobs", good_job_url, class: "text-white underline hover:text-gray-100" %>
8+
</div>
9+
610
<div class="flex items-center space-x-2 px-2 py-2 text-white">
711
<% if Current.session.active_impersonator_session.present? %>
812
<div class="flex items-center space-x-3 bg-gray-800 border border-gray-700 rounded-md pl-3">

config/initializers/good_job.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@
1010
}
1111
}
1212
end
13+
14+
# Auth for jobs admin dashboard
15+
ActiveSupport.on_load(:good_job_application_controller) do
16+
before_action do
17+
raise ActionController::RoutingError.new("Not Found") unless current_user&.super_admin?
18+
end
19+
20+
def current_user
21+
session = Session.find_by(id: cookies.signed[:session_token])
22+
session&.user
23+
end
24+
end
1325
end

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Rails.application.routes.draw do
2+
mount GoodJob::Engine => "good_job"
3+
24
get "changelog", to: "pages#changelog"
35
get "feedback", to: "pages#feedback"
46
get "early-access", to: "pages#early_access"

test/controllers/sessions_controller_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,15 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
3131
assert_redirected_to new_session_path
3232
assert_equal "You have signed out successfully.", flash[:notice]
3333
end
34+
35+
test "super admins can access the jobs page" do
36+
sign_in users(:maybe_support_staff)
37+
get good_job_url
38+
assert_redirected_to "http://www.example.com/good_job/jobs?locale=en"
39+
end
40+
41+
test "non-super admins cannot access the jobs page" do
42+
get good_job_url
43+
assert_response :not_found
44+
end
3445
end

0 commit comments

Comments
 (0)