Skip to content
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

Add custom redirect url #63

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/omniauth/strategies/linkedin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class LinkedIn < OmniAuth::Strategies::OAuth2
option :scope, 'r_liteprofile r_emailaddress'
option :fields, ['id', 'first-name', 'last-name', 'picture-url', 'email-address']

option :redirect_url

uid do
raw_info['id']
end
Expand All @@ -34,6 +36,9 @@ class LinkedIn < OmniAuth::Strategies::OAuth2
end

def callback_url
if options.redirect_url
return options.redirect_url
end
full_host + script_name + callback_path
end

Expand Down
9 changes: 9 additions & 0 deletions spec/omniauth/strategies/linkedin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
end
end

describe '#custom redirect_url' do
let(:redirect_url) {'http://localhost:3001'}

it 'custom redirect' do
expect(subject.callback_url).to eq('http://localhost:3001')
end

end

describe '#uid' do
before :each do
allow(subject).to receive(:raw_info) { Hash['id' => 'uid'] }
Expand Down