2018-09-23 19:44:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-30 17:06:18 +00:00
|
|
|
class Profiles::AccountsController < Profiles::ApplicationController
|
2017-03-28 10:33:51 +00:00
|
|
|
include AuthHelper
|
|
|
|
|
2020-10-08 18:08:32 +00:00
|
|
|
feature_category :users
|
|
|
|
|
2013-10-09 13:37:18 +00:00
|
|
|
def show
|
2018-12-04 10:31:11 +00:00
|
|
|
render(locals: show_view_variables)
|
2013-10-09 13:37:18 +00:00
|
|
|
end
|
2015-03-22 00:44:40 +00:00
|
|
|
|
|
|
|
def unlink
|
|
|
|
provider = params[:provider]
|
2020-09-10 18:08:54 +00:00
|
|
|
identity = find_identity(provider)
|
2017-03-28 10:33:51 +00:00
|
|
|
|
|
|
|
return render_404 unless identity
|
|
|
|
|
2019-03-18 14:36:34 +00:00
|
|
|
if unlink_provider_allowed?(provider)
|
2017-03-28 10:33:51 +00:00
|
|
|
identity.destroy
|
|
|
|
else
|
2019-05-17 05:59:31 +00:00
|
|
|
flash[:alert] = _("You are not allowed to unlink your primary login account")
|
2017-03-28 10:33:51 +00:00
|
|
|
end
|
|
|
|
|
2015-03-22 00:44:40 +00:00
|
|
|
redirect_to profile_account_path
|
|
|
|
end
|
2018-12-04 10:31:11 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def show_view_variables
|
2018-12-04 10:17:21 +00:00
|
|
|
{}
|
2018-12-04 10:31:11 +00:00
|
|
|
end
|
2020-09-10 18:08:54 +00:00
|
|
|
|
|
|
|
def find_identity(provider)
|
|
|
|
return current_user.atlassian_identity if provider == 'atlassian_oauth2'
|
|
|
|
|
|
|
|
current_user.identities.find_by(provider: provider) # rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
end
|
2013-10-09 13:37:18 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
Profiles::AccountsController.prepend_if_ee('EE::Profiles::AccountsController')
|