Skip to content

Commit

Permalink
Merge pull request #933 from alphagov/remove-current-user-method
Browse files Browse the repository at this point in the history
Remove the current_user method from Delayed::Web
  • Loading branch information
pixeltrix authored May 23, 2024
2 parents 1368fb3 + 2704d1c commit a0caeaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions config/initializers/delayed_web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
Delayed::Web::ApplicationController.class_eval do
include FlashI18n

rescue_from ActiveRecord::RecordNotFound do
redirect_to root_url, notice: t(:notice, scope: 'delayed/web.flashes.jobs.not_found')
end

before_action :require_admin

def admin_request?
Expand All @@ -18,10 +22,6 @@ def admin_login_url
main_app.admin_login_url
end

def current_user
@current_user ||= warden.authenticate(scope: :user)
end

def require_admin
unless current_user
redirect_to admin_login_url, alert: :admin_required
Expand Down
2 changes: 2 additions & 0 deletions config/locales/delayed_web.en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ en-GB:
destroyed:
alert: 'Job cannot be deleted because it is already %{status}'
notice: 'Job destroyed'
not_found:
notice: 'Job not found'

0 comments on commit a0caeaf

Please sign in to comment.