diff --git a/app/controllers/api/v1/leaderboard_controller.rb b/app/controllers/api/v1/leaderboard_controller.rb index 6b14bc2..70f3d1f 100644 --- a/app/controllers/api/v1/leaderboard_controller.rb +++ b/app/controllers/api/v1/leaderboard_controller.rb @@ -1,6 +1,7 @@ class Api::V1::LeaderboardController < ApplicationController skip_before_action :verify_authenticity_token skip_before_action :authenticate + ACCESS_TOKEN = "ikea-tomato-2026" before_action :set_cors_headers, :set_locale_to_default, :verify_access_token diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index aff3ca0..37dfeff 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,8 +1,13 @@ class ApplicationController < ActionController::Base - http_basic_authenticate_with name: "stupid", password: "studio" if Rails.env.production? + before_action :authenticate + private + def authenticate + http_basic_authenticate_with name: "stupid", password: "studio" if Rails.env.production? + end + def set_locale I18n.locale = params[:locale].presence_in(I18n.available_locales.map(&:to_s)) || I18n.default_locale @@ -12,4 +17,6 @@ private def not_found raise ActionController::RoutingError.new("Not Found") end + + end