price-point-api/app/controllers/application_controller.rb
Mohammad Kanaan 54bdd52e75
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
feat: add user auth and bcrypt gem with related schema updates
2026-05-31 00:27:35 +03:00

15 lines
364 B
Ruby

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