diff --git a/app/controllers/doorkeeper/authorizations_controller.rb b/app/controllers/doorkeeper/authorizations_controller.rb index 88d5aae1b..60e34aaa9 100644 --- a/app/controllers/doorkeeper/authorizations_controller.rb +++ b/app/controllers/doorkeeper/authorizations_controller.rb @@ -24,6 +24,7 @@ def destroy def render_success if skip_authorization? || matching_token? auth = authorization.authorize + after_successful_authorization redirect_or_render auth elsif Doorkeeper.configuration.api_only render json: pre_auth @@ -79,5 +80,9 @@ def authorization def strategy @strategy ||= server.authorization_request pre_auth.response_type end + + def after_successful_authorization + Doorkeeper.configuration.after_successful_authorization.call(self) + end end end diff --git a/lib/doorkeeper/config.rb b/lib/doorkeeper/config.rb index 4b2bba66d..8940a7ecb 100644 --- a/lib/doorkeeper/config.rb +++ b/lib/doorkeeper/config.rb @@ -217,6 +217,7 @@ def option(name, options = {}) ::Rails.logger.warn(I18n.t('doorkeeper.errors.messages.credential_flow_not_configured')) nil end) + option :after_successful_authorization, default: ->(_controller) {} option :before_successful_strategy_response, default: ->(_request) {} option :after_successful_strategy_response, default: ->(_request, _response) {}