summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/enforces_admin_authentication.rb
blob: 3ef92730df6b1f063cb1ee301634dc8b42d66bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

# == EnforcesAdminAuthentication
#
# Controller concern to enforce that users are authenticated as admins
#
# Upon inclusion, adds `authenticate_admin!` as a before_action
#
module EnforcesAdminAuthentication
  extend ActiveSupport::Concern

  included do
    before_action :authenticate_admin!
  end

  def authenticate_admin!
    render_404 unless current_user.admin?
  end
end