1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-20 21:59:38 +02:00

Add back good job dashboard with auth (#1364)

This commit is contained in:
Zach Gollwitzer 2024-10-24 17:28:29 -04:00 committed by GitHub
parent ba49fea89a
commit b611dfdf37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 0 deletions

View file

@ -3,6 +3,10 @@
<%= lucide_icon "alert-triangle", class: "w-6 h-6 text-white mr-2" %> <%= lucide_icon "alert-triangle", class: "w-6 h-6 text-white mr-2" %>
<span class="text-white font-semibold uppercase">Super Admin</span> <span class="text-white font-semibold uppercase">Super Admin</span>
</div> </div>
<div>
<%= link_to "Jobs", good_job_url, class: "text-white underline hover:text-gray-100" %>
</div>
<div class="flex items-center space-x-2 px-2 py-2 text-white"> <div class="flex items-center space-x-2 px-2 py-2 text-white">
<% if Current.session.active_impersonator_session.present? %> <% if Current.session.active_impersonator_session.present? %>
<div class="flex items-center space-x-3 bg-gray-800 border border-gray-700 rounded-md pl-3"> <div class="flex items-center space-x-3 bg-gray-800 border border-gray-700 rounded-md pl-3">

View file

@ -10,4 +10,16 @@ Rails.application.configure do
} }
} }
end 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 end

View file

@ -1,4 +1,6 @@
Rails.application.routes.draw do Rails.application.routes.draw do
mount GoodJob::Engine => "good_job"
get "changelog", to: "pages#changelog" get "changelog", to: "pages#changelog"
get "feedback", to: "pages#feedback" get "feedback", to: "pages#feedback"
get "early-access", to: "pages#early_access" get "early-access", to: "pages#early_access"

View file

@ -31,4 +31,15 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to new_session_path assert_redirected_to new_session_path
assert_equal "You have signed out successfully.", flash[:notice] assert_equal "You have signed out successfully.", flash[:notice]
end 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 end