2026-05-17 11:12:43 +00:00
|
|
|
class ApplicationController < ActionController::API
|
2026-05-30 21:27:35 +00:00
|
|
|
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
|