2018-09-23 15:44:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-30 13:06:18 -04:00
|
|
|
class Profiles::AccountsController < Profiles::ApplicationController
|
2017-03-28 06:33:51 -04:00
|
|
|
include AuthHelper
|
|
|
|
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :users
|
|
|
|
|
2013-10-09 09:37:18 -04:00
|
|
|
def show
|
2018-12-04 05:31:11 -05:00
|
|
|
render(locals: show_view_variables)
|
2013-10-09 09:37:18 -04:00
|
|
|
end
|
2015-03-21 20:44:40 -04:00
|
|
|
|
|
|
|
def unlink
|
|
|
|
provider = params[:provider]
|
2020-09-10 14:08:54 -04:00
|
|
|
identity = find_identity(provider)
|
2017-03-28 06:33:51 -04:00
|
|
|
|
|
|
|
return render_404 unless identity
|
|
|
|
|
2019-03-18 10:36:34 -04:00
|
|
|
if unlink_provider_allowed?(provider)
|
2017-03-28 06:33:51 -04:00
|
|
|
identity.destroy
|
|
|
|
else
|
2019-05-17 01:59:31 -04:00
|
|
|
flash[:alert] = _("You are not allowed to unlink your primary login account")
|
2017-03-28 06:33:51 -04:00
|
|
|
end
|
|
|
|
|
2015-03-21 20:44:40 -04:00
|
|
|
redirect_to profile_account_path
|
|
|
|
end
|
2018-12-04 05:31:11 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def show_view_variables
|
2018-12-04 05:17:21 -05:00
|
|
|
{}
|
2018-12-04 05:31:11 -05:00
|
|
|
end
|
2020-09-10 14:08:54 -04: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 09:37:18 -04:00
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Profiles::AccountsController.prepend_mod_with('Profiles::AccountsController')
|