-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added :after_successful_authorization callback #1064
Added :after_successful_authorization callback #1064
Conversation
it 'should call :after_successful_authorization callback' do | ||
expect(Doorkeeper.configuration) | ||
.to receive_message_chain(:after_successful_authorization, :call) | ||
.with(instance_of(described_class)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
|
||
it 'should call :after_successful_authorization callback' do | ||
expect(Doorkeeper.configuration) | ||
.to receive_message_chain(:after_successful_authorization, :call) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
after do | ||
allow(Doorkeeper.configuration) | ||
.to receive(:skip_authorization) | ||
.and_return(proc { true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
describe 'GET #new with callbacks' do | ||
after do | ||
allow(Doorkeeper.configuration) | ||
.to receive(:skip_authorization) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
it 'should call :after_successful_authorization callback' do | ||
expect(Doorkeeper.configuration) | ||
.to receive_message_chain(:after_successful_authorization, :call) | ||
.with(instance_of(described_class)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
|
||
it 'should call :after_successful_authorization callback' do | ||
expect(Doorkeeper.configuration) | ||
.to receive_message_chain(:after_successful_authorization, :call) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
after do | ||
allow(Doorkeeper.configuration) | ||
.to receive(:skip_authorization) | ||
.and_return(proc { true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
describe 'GET #new with callbacks' do | ||
after do | ||
allow(Doorkeeper.configuration) | ||
.to receive(:skip_authorization) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Place the . on the previous line, together with the method call receiver.
a16de71
to
1885305
Compare
lib/doorkeeper/config.rb
Outdated
@@ -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) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary spacing detected.
1885305
to
2b5e3d1
Compare
@@ -24,6 +24,7 @@ def destroy | |||
def render_success |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add before
hook? I think it can be useful for some purposes, moreover it will comply with other Doorkeeper hooks
lib/doorkeeper/config.rb
Outdated
@@ -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) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename _controller
to _context
Just small fixes for comments above and it would be great 👍 Also after finishing the work - could you please add a changelog entry to NEWS.md and squash all commits to a single one? Thanks |
3f36e1f
to
42126a7
Compare
They expose AuthorizationController context in the :new method Use cases: for example, when you need to set some cookies after successful authorization
42126a7
to
842f450
Compare
@nbulaj it's all done, thank you for your points :) |
Thank you for your work! |
Summary
This PR adds an ability to run some code after successful authorization. TLDR: #1062
Example: