Skip to content

Commit

Permalink
clean rails performance page security route check
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 5, 2024
1 parent 8b858f2 commit 238077f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
root to: 'home#index'
mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?

constraints(lambda { |req| req.session[:user].admin? }) do
mount RailsPerformance::Engine, at: '/rails/performance'
end

constraints(lambda { |req| !req.session[:user].admin? }) do
get '/rails/performance', to: redirect('/login?redirect=/rails/performance')
constraints(lambda { |req| req.session[:user].present? || req.session[:user].nil? }) do
if req.session[:user]&.admin?
mount RailsPerformance::Engine, at: '/rails/performance'
else
get '/rails/performance', to: redirect('/login?redirect=/rails/performance')
end
end

get '/tools', to: 'home#tools'
Expand Down

0 comments on commit 238077f

Please sign in to comment.