2019-11-28 06:16:25 +08:00
|
|
|
module Users
|
|
|
|
module Settings
|
|
|
|
module Account
|
|
|
|
class ConnectedAccountsController < ApplicationController
|
|
|
|
layout 'fluid'
|
|
|
|
|
|
|
|
def index
|
|
|
|
@linked_accounts = current_user.user_identities.pluck(:provider)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2023-09-05 18:53:51 +08:00
|
|
|
user_identity = current_user.user_identities.find_by(provider: params[:provider])
|
|
|
|
if user_identity.blank?
|
|
|
|
flash.now[:error] = t('users.settings.account.connected_accounts.errors.not_found')
|
2019-12-12 21:57:27 +08:00
|
|
|
return
|
|
|
|
end
|
2023-09-05 18:53:51 +08:00
|
|
|
user_identity.destroy!
|
|
|
|
flash.now[:success] = t('users.settings.account.connected_accounts.unlink_success')
|
2019-12-12 21:57:27 +08:00
|
|
|
rescue StandardError
|
2023-09-05 18:53:51 +08:00
|
|
|
flash.now[:error] ||= t('users.settings.account.connected_accounts.errors.generic')
|
2019-12-12 21:57:27 +08:00
|
|
|
ensure
|
2019-11-28 06:16:25 +08:00
|
|
|
@linked_accounts = current_user.user_identities.pluck(:provider)
|
|
|
|
render :index
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|