price-point-api/app/controllers/application_controller.rb

16 lines
364 B
Ruby
Raw Normal View History

2026-05-17 11:12:43 +00:00
class ApplicationController < ActionController::API
before_action :authenticate!
private
def authenticate!
token = request.headers["Authorization"]&.split(" ")&.last
@current_user = User.find_by(token:)
render json: { error: "Unauthorized" }, status: :unauthorized unless @current_user
end
def current_user
@current_user
end
2026-05-17 11:12:43 +00:00
end