Skip to content

Commit

Permalink
Remove pundit and related code from Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Jan 18, 2025
1 parent cec3c2a commit 674735c
Show file tree
Hide file tree
Showing 25 changed files with 22 additions and 897 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ gem 'omniauth-rails_csrf_protection'
gem 'postmark-rails'
gem 'prophet-rb', '~> 0.5.3'
gem 'puma'
gem 'pundit'
gem 'rails', '8.0.1'
gem 'rails-html-sanitizer'
gem 'rack-cors', '~> 2.0'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,6 @@ GEM
public_suffix (6.0.1)
puma (6.5.0)
nio4r (~> 2.0)
pundit (2.4.0)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.1)
rack (3.1.8)
Expand Down Expand Up @@ -591,7 +589,6 @@ DEPENDENCIES
postmark-rails
prophet-rb (~> 0.5.3)
puma
pundit
rack-cors (~> 2.0)
rails (= 8.0.1)
rails-controller-testing
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# rubocop:disable Rails/ApplicationController
module Api
class ApiController < ActionController::Base
include Pundit::Authorization
include Authentication::CurrentUserManager
include Authentication::CurrentCaseManager
include Authentication::CurrentQueryManager
Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/v1/current_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Api
module V1
class CurrentUserController < Api::ApiController
def show
@permissions = PermissionsEvaluator.new(current_user).run
@user = current_user

respond_with @user
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/api/v1/scorers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,7 @@ def create

# rubocop:disable Metrics/MethodLength
def update
# this method could be used instead of the below @scorer.owner == current_user logic
# authorize @scorer, :update_communal?

# the policy() call is provided by Pundit and leverages the Permissions data structures.
# using this check instead of the authorize because it raises an exception.
unless @scorer.owner == current_user || (@scorer.communal && policy(@scorer).update_communal?)
unless @scorer.owner == current_user || (@scorer.communal && current_user.administrator?)
render(
json: {
error: 'Cannot edit a scorer you do not own',
Expand Down
245 changes: 0 additions & 245 deletions app/models/concerns/permissible.rb

This file was deleted.

30 changes: 0 additions & 30 deletions app/models/permission.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ class User < ApplicationRecord
through: :teams,
source: :scorers

has_many :permissions,
dependent: :destroy

has_many :scores,
dependent: :destroy

Expand Down Expand Up @@ -210,7 +207,6 @@ def store_raw_invitation_token
# END devise hacks

# Concerns
include Permissible
include Profile

# Scopes
Expand Down
Loading

0 comments on commit 674735c

Please sign in to comment.