You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: base_controller.rb
    path of file: ./repos/datoji/app/controllers
    
    the code of the file until where you have to start completion: require 'pagy/extras/headers'
require 'pagy/extras/array'

class BaseController < ApplicationController
  include Response
  include Except
    
  def authenticate_token
    authenticate_or_request_with_http_token do |token, _|
      if (api_token = Token.active.find_by(key: token))
        # Compare the tokens in a time-constant manner, to mitigate timing attacks.
        ActiveSupport::SecurityUtils.secure_compare(
          ::Digest::SHA256.hexdigest(token),
          ::Digest::SHA256.hexdigest(api_token.key)
        )
        api_token
      end
    end