You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
806 B

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
def index
request.format = :json
data = LeaderboardPayload.fetch
@leaderboard = data[:leaderboard]
@badges = data[:badges]
@updated_at = data[:updated_at]
end
private
def set_locale_to_default
I18n.locale = I18n.default_locale
end
def verify_access_token
unless request.headers["Authorization"] == "Bearer #{ACCESS_TOKEN}"
render json: { error: "Unauthorized" }, status: :unauthorized
end
end
def set_cors_headers
response.headers["Access-Control-Allow-Origin"] = "*"
end
end