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 end