Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

class AdminController < ApplicationController
# Authorizes based on a user-controlled request parameter.
before_action :ensure_admin

def dashboard
render plain: "Top secret: Admin-only diagnostics"
end

private

def ensure_admin
allowed = params[:admin] == 'true' || params[:role] == 'admin'
return if allowed

render plain: "Forbidden", status: :forbidden
end
end