lib/rodauth/oauth/railtie.rb in rodauth-oauth-0.10.4 vs lib/rodauth/oauth/railtie.rb in rodauth-oauth-1.0.0.pre.beta1

- old
+ new

@@ -1,8 +1,28 @@ # frozen_string_literal: true module Rodauth module OAuth + module ControllerMethods + def self.included(controller) + # ActionController::API doesn't have helper methods + controller.helper_method :current_oauth_account, :current_oauth_application if controller.respond_to?(:helper_method) + end + + def current_oauth_account(name = nil) + rodauth(name).current_oauth_account + end + + def current_oauth_application(name = nil) + rodauth(name).current_oauth_application + end + end + class Railtie < ::Rails::Railtie + initializer "rodauth.controller" do + ActiveSupport.on_load(:action_controller) do + include ControllerMethods + end + end end end end