class AdminSignedInConstraint
  def matches?(request)
    signed_in?(request) && signed_in_user_is_admin?(request)
  end

  def signed_in?(request)
    Oath::Constraints::SignedIn.new.matches?(request)
  end

  def signed_in_user_is_admin?(request)
    warden = request.env['warden']
    warden && warden.user.admin?
  end
end
