mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 22:25:30 +08:00
32 lines
1.1 KiB
Ruby
32 lines
1.1 KiB
Ruby
module Users
|
|
module Settings
|
|
module Account
|
|
class ConnectedAccountsController < ApplicationController
|
|
layout 'fluid'
|
|
|
|
def index
|
|
@linked_accounts = current_user.user_identities.pluck(:provider)
|
|
end
|
|
|
|
def destroy
|
|
if Rails.configuration.x.azure_ad_apps.select { |_, v| v[:provider] == params[:provider] }.present?
|
|
provider = params[:provider]
|
|
else
|
|
flash[:error] = t('users.settings.account.connected_accounts.errors.not_found')
|
|
return
|
|
end
|
|
ActiveRecord::Base.transaction do
|
|
__send__("#{provider}_pre_destroy".to_sym) if respond_to?("#{provider}_pre_destroy".to_sym, true)
|
|
current_user.user_identities.where(provider: provider).take&.destroy!
|
|
end
|
|
flash[:success] = t('users.settings.account.connected_accounts.unlink_success')
|
|
rescue StandardError
|
|
flash[:error] ||= t('users.settings.account.connected_accounts.errors.generic')
|
|
ensure
|
|
@linked_accounts = current_user.user_identities.pluck(:provider)
|
|
render :index
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|