2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
class Profiles::AccountsController < Profiles::ApplicationController
|
2017-08-17 22:00:37 +05:30
|
|
|
include AuthHelper
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
feature_category :users
|
2022-07-16 23:28:13 +05:30
|
|
|
urgency :low, [:show]
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
def show
|
2019-02-15 15:39:39 +05:30
|
|
|
render(locals: show_view_variables)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
def unlink
|
|
|
|
provider = params[:provider]
|
2020-11-24 15:15:51 +05:30
|
|
|
identity = find_identity(provider)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
return render_404 unless identity
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
if unlink_provider_allowed?(provider)
|
2017-08-17 22:00:37 +05:30
|
|
|
identity.destroy
|
|
|
|
else
|
2019-09-04 21:01:54 +05:30
|
|
|
flash[:alert] = _("You are not allowed to unlink your primary login account")
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
redirect_to profile_account_path
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def show_view_variables
|
|
|
|
{}
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Profiles::AccountsController.prepend_mod_with('Profiles::AccountsController')
|