Skip to content

Commit

Permalink
Fix obscure bug
Browse files Browse the repository at this point in the history
  • Loading branch information
santib committed Nov 10, 2023
1 parent 474ded6 commit df3a75a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 2 additions & 7 deletions app/controllers/api/v1/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@ class ApiController < ActionController::API
include Pundit::Authorization
include DeviseTokenAuth::Concerns::SetUserByToken

before_action :authenticate_user!

after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index

before_action :authenticate_user!, except: :status
skip_after_action :verify_authorized, only: :status

rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
rescue_from ActiveRecord::RecordInvalid, with: :render_record_invalid
rescue_from ActionController::ParameterMissing, with: :render_parameter_missing

def status
render json: { online: true }
end

private

def render_not_found(exception)
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/api/v1/health_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module Api
module V1
class HealthController < Api::V1::ApiController
skip_before_action :authenticate_user!
skip_after_action :verify_authorized

def status
render json: { online: true }
end
end
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace :api do
namespace :v1, defaults: { format: :json } do
get :status, to: 'api#status'
get :status, to: 'health#status'

devise_scope :user do
resource :user, only: %i[update show]
Expand Down

0 comments on commit df3a75a

Please sign in to comment.