I have this following controller for my application:
class Api::BaseApiController< ApplicationController
before_action :parse_request, :authenticate_member_from_token!
def index
render nothing: true, status: 200
end
protected
def authenticate_member_from_token!
if !request.headers[:escambo_token]
@member = Member.find_by_valid_token(:activate, request.headers['escambo_token'])
if !@member
render nothing: true, status: :unauthorized
end
end
end
Then, I have another controller that inherits from that Controller:
class Api::CategoryController < Api::BaseApiController
before_action :find_category, except: [:index]
def index
@category = Category.all
puts(@category)
render json: @category
end
But the controller is allowing requests without the token.
EDIT 1: for some reason the index
action started to working normally. But still not doing the validation for the token.
EDIT 2: fixing method from private
to protected