remove user profile linkedin integration

leave gem and authentication provider alone for now

test plan:
* the button on user settings page to integrate with
linked in should no longer be shown
* logging in through linked in should work as before

flag=none
closes #LA-4

Change-Id: I8e7ac10df27454db90a14d636ff0f4317978c289
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/216617
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Tested-by: Jenkins
QA-Review: Carl Kibler <ckibler@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
James Williams 2019-11-11 07:49:45 -07:00
parent b82d94d445
commit 7a3ed9419f
8 changed files with 29 additions and 136 deletions

View File

@ -1882,8 +1882,6 @@ class ApplicationController < ActionController::Base
true
elsif feature == :twitter
!!Twitter::Connection.config
elsif feature == :linked_in
!!LinkedIn::Connection.config
elsif feature == :diigo
!!Diigo::Connection.config
elsif feature == :google_drive

View File

@ -261,20 +261,6 @@ class UsersController < ApplicationController
:user => @current_user,
:original_host_with_port => request.host_with_port
)
redirect_to request_token.authorize_url
elsif params[:service] == "linked_in"
success_url = oauth_success_url(:service => 'linked_in')
request_token = LinkedIn::Connection.request_token(success_url)
OauthRequest.create(
:service => 'linked_in',
:token => request_token.token,
:secret => request_token.secret,
:return_url => return_to_url,
:user => @current_user,
:original_host_with_port => request.host_with_port
)
redirect_to request_token.authorize_url
end
end
@ -340,56 +326,28 @@ class UsersController < ApplicationController
url = url_for request.parameters.merge(:host => oauth_request.original_host_with_port, :only_path => false)
redirect_to url
else
if params[:service] == "linked_in"
begin
raise "No OAuth LinkedIn User" unless oauth_request.user
begin
raise "No OAuth Twitter User" unless oauth_request.user
linkedin = LinkedIn::Connection.from_request_token(
oauth_request.token,
oauth_request.secret,
params[:oauth_verifier]
)
twitter = Twitter::Connection.from_request_token(
oauth_request.token,
oauth_request.secret,
params[:oauth_verifier]
)
UserService.register(
:service => "twitter",
:access_token => twitter.access_token,
:user => oauth_request.user,
:service_domain => "twitter.com",
:service_user_id => twitter.service_user_id,
:service_user_name => twitter.service_user_name
)
oauth_request.destroy
UserService.register(
:service => "linked_in",
:access_token => linkedin.access_token,
:user => oauth_request.user,
:service_domain => "linked_in.com",
:service_user_id => linkedin.service_user_id,
:service_user_name => linkedin.service_user_name,
:service_user_url => linkedin.service_user_url
)
oauth_request.destroy
flash[:notice] = t('linkedin_added', "LinkedIn account successfully added!")
rescue => e
Canvas::Errors.capture_exception(:oauth, e)
flash[:error] = t('linkedin_fail', "LinkedIn authorization failed. Please try again")
end
else
begin
raise "No OAuth Twitter User" unless oauth_request.user
twitter = Twitter::Connection.from_request_token(
oauth_request.token,
oauth_request.secret,
params[:oauth_verifier]
)
UserService.register(
:service => "twitter",
:access_token => twitter.access_token,
:user => oauth_request.user,
:service_domain => "twitter.com",
:service_user_id => twitter.service_user_id,
:service_user_name => twitter.service_user_name
)
oauth_request.destroy
flash[:notice] = t('twitter_added', "Twitter access authorized!")
rescue => e
Canvas::Errors.capture_exception(:oauth, e)
flash[:error] = t('twitter_fail_whale', "Twitter authorization failed. Please try again")
end
flash[:notice] = t('twitter_added', "Twitter access authorized!")
rescue => e
Canvas::Errors.capture_exception(:oauth, e)
flash[:error] = t('twitter_fail_whale', "Twitter authorization failed. Please try again")
end
return_to(oauth_request.return_url, user_profile_url(@current_user))
end

View File

@ -154,8 +154,6 @@ class UserService < ActiveRecord::Base
3
when CommunicationChannel::TYPE_TWITTER
4
when 'linked_in'
6
when 'delicious'
7
when 'diigo'
@ -177,8 +175,6 @@ class UserService < ActiveRecord::Base
t '#user_service.descriptions.delicious', 'Delicious is a collaborative link-sharing tool. You can tag any page on the Internet for later reference. You can also link to other users\' Delicious accounts to share links of similar interest.'
when 'diigo'
t '#user_service.descriptions.diigo', 'Diigo is a collaborative link-sharing tool. You can tag any page on the Internet for later reference. You can also link to other users\' Diigo accounts to share links of similar interest.'
when 'linked_in'
t '#user_service.descriptions.linked_in', 'LinkedIn is a resource for business networking. Many of the relationships you build while in school can also be helpful once you enter the workplace.'
when 'skype'
t '#user_service.descriptions.skype', 'Skype is a free tool for online voice and video calls.'
else
@ -198,8 +194,6 @@ class UserService < ActiveRecord::Base
'http://delicious.com/'
when 'diigo'
'https://www.diigo.com/sign-up'
when 'linked_in'
'https://www.linkedin.com/reg/join'
when 'skype'
'http://www.skype.com/go/register'
else
@ -219,8 +213,6 @@ class UserService < ActiveRecord::Base
"http://www.delicious.com/#{service_user_name}"
when 'diigo'
"http://www.diigo.com/user/#{service_user_name}"
when 'linked_in'
service_user_url
when 'skype'
"skype:#{service_user_name}?add"
else
@ -229,7 +221,7 @@ class UserService < ActiveRecord::Base
end
def self.configured_services
[:google_drive, :twitter, :linked_in, :diigo]
[:google_drive, :twitter, :diigo]
end
def self.configured_service?(service)

View File

@ -205,13 +205,6 @@
}
}
.linked_in {
background-position: -97px 0;
&:hover {
background-position: -97px -32px;
}
}
.delicious {
background-position: -129px 0;
&:hover {

View File

@ -348,28 +348,6 @@ TEXT
</div>
</div>
</li>
<li id="unregistered_service_linked_in" class="service" style="<%= hidden if services.include?("linked_in") || !feature_and_service_enabled?(:linked_in) %>">
<a href="#" class="btn btn-small"><%= image_tag "linked_in_icon.png", :alt => '' %> <%= t('links.linkedin', "LinkedIn") %></a>
<div style="display: none; text-align: <%= direction('left') %>;" class="content" title="<%= t('titles.authorize_linkedin', "Authorize LinkedIn") %>" id="unregistered_service_linked_in_dialog">
<div>
<%= image_tag "linked_in.png", :style => "float: #{direction('left')}; padding-#{ direction('right') }: 5px;", :alt => '' %>
<div style="font-size: 1.2em; font-weight: bold;"><%= t('headers.linkedin_access', "LinkedIn Access") %></div>
<%= t(:linkedin_description, <<-TEXT)
LinkedIn is a great resources for business networking, and can be
helpful long after you've finished your education.
If you have a LinkedIn account, you can register it here. Then if you
allow fellow course/group members to see your registered services, they
can easily invite you to link with them without having to search LinkedIn
for your profile.
TEXT
%>
<div class="clear"></div>
</div>
<div style="text-align: center; font-size: 1.2em; margin-top: 10px;">
<a class="btn btn-primary" href="<%= oauth_url(:service => "linked_in", :return_to => settings_profile_url) %>"><%= t('buttons.register_linkedin_account', "Register Your LinkedIn Account") %></a>
</div>
</div>
</li>
<li id="unregistered_service_twitter" class="service" style="<%= hidden if services.include?("twitter") || !feature_and_service_enabled?(:twitter) %>">
<a href="#" class="btn btn-small"><%= image_tag "twitter_icon.png", :alt => '' %> <%= t('links.twitter', "Twitter") %></a>
<div style="display: none; text-align: <%= direction('left') %>;" class="content" title="<%= t('titles.authorize_twitter', "Authorize Twitter") %>" id="unregistered_service_twitter_dialog">

View File

@ -39,12 +39,6 @@ module AccountServices
:description => "",
:expose_to_ui => :service
},
:linked_in => {
:name => I18n.t("LinkedIn"),
:description => "",
:expose_to_ui => :service,
:expose_to_ui_proc => proc { !!LinkedIn::Connection.config }
},
:twitter => {
:name => I18n.t("Twitter"),
:description => "",

View File

@ -18,7 +18,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
%w{ Twitter LinkedIn }.each do |integration|
%w{ Twitter }.each do |integration|
describe integration do
before do
course_with_student_logged_in(:active_all => true)
@ -26,9 +26,7 @@ describe integration do
def oauth_start(integration)
expect_any_instance_of(UsersController).to receive(:feature_and_service_enabled?).with(integration.underscore).and_return(true)
if integration == "LinkedIn"
expect(LinkedIn::Connection).to receive(:config).at_least(:once).and_return({})
elsif integration == "Twitter"
if integration == "Twitter"
expect(Twitter::Connection).to receive(:config).at_least(:once).and_return({})
else
expect(integration.constantize).to receive(:config).at_least(:once).and_return({})
@ -93,14 +91,7 @@ describe integration do
it "should create the UserService on successful auth" do
oauth_start(integration)
if integration == "LinkedIn"
expect(LinkedIn::Connection).to receive(:from_request_token).and_return(double("LinkedInConnection",
access_token: double("AccessToken", token: 'test_token', secret: 'test_secret'),
service_user_id: "test_user_id",
service_user_name: "test_user_name",
service_user_url: "test_user_url"
))
elsif integration == "Twitter"
if integration == "Twitter"
expect(Twitter::Connection).to receive(:from_request_token).and_return(double("TwitterConnection",
access_token: double("AccessToken", token: 'test_token', secret: 'test_secret'),
service_user_id: "test_user_id",
@ -124,11 +115,7 @@ describe integration do
oauth_start(integration)
# pretend that somehow we think we got a valid auth token, but we actually didn't
if integration == "LinkedIn"
# mock up the response from the 3rd party service, so we don't actually contact it
expect(LinkedIn::Connection).to receive(:from_request_token).
and_raise(RuntimeError, "Third-party service totally like, failed")
elsif integration == "Twitter"
if integration == "Twitter"
expect(Twitter::Connection).to receive(:from_request_token).
and_raise(RuntimeError, "Third-party service totally like, failed")
end

View File

@ -250,23 +250,20 @@ describe Account do
@a = Account.new
end
it "should be able to specify a list of enabled services" do
@a.allowed_services = 'linked_in,twitter'
expect(@a.service_enabled?(:linked_in)).to be_truthy
@a.allowed_services = 'twitter'
expect(@a.service_enabled?(:twitter)).to be_truthy
expect(@a.service_enabled?(:diigo)).to be_falsey
expect(@a.service_enabled?(:avatars)).to be_falsey
end
it "should not enable services off by default" do
expect(@a.service_enabled?(:linked_in)).to be_truthy
expect(@a.service_enabled?(:avatars)).to be_falsey
end
it "should add and remove services from the defaults" do
@a.allowed_services = '+avatars,-linked_in'
@a.allowed_services = '+avatars,-twitter'
expect(@a.service_enabled?(:avatars)).to be_truthy
expect(@a.service_enabled?(:twitter)).to be_truthy
expect(@a.service_enabled?(:linked_in)).to be_falsey
expect(@a.service_enabled?(:twitter)).to be_falsey
end
it "should allow settings services" do
@ -297,17 +294,13 @@ describe Account do
end
it "should be able to set service availibity for previously hard-coded values" do
@a.allowed_services = 'avatars,linked_in'
@a.allowed_services = 'avatars'
@a.enable_service(:twitter)
expect(@a.service_enabled?(:twitter)).to be_truthy
expect(@a.allowed_services).to match(/twitter/)
expect(@a.allowed_services).not_to match(/[+-]/)
@a.disable_service(:linked_in)
expect(@a.allowed_services).not_to match(/linked_in/)
expect(@a.allowed_services).not_to match(/[+-]/)
@a.disable_service(:avatars)
@a.disable_service(:twitter)
expect(@a.allowed_services).to be_nil