Skip to content

Commit

Permalink
Added :after_successful_authorization callback
Browse files Browse the repository at this point in the history
  • Loading branch information
nattfodd committed Mar 26, 2018
1 parent e8474c4 commit 2ba531b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/doorkeeper/authorizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions lib/doorkeeper/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down

0 comments on commit 2ba531b

Please sign in to comment.