Move account deletion to Sidekiq worker, fixes #11
This commit is contained in:
parent
d3ebaf395f
commit
3a5dcbcd3b
|
@ -0,0 +1,10 @@
|
||||||
|
class User::RegistrationsController < Devise::RegistrationsController
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
DeletionWorker.perform_async(resource.id)
|
||||||
|
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
||||||
|
set_flash_message :notice, :destroyed if is_flashing_format?
|
||||||
|
yield resource if block_given?
|
||||||
|
respond_with_navigational(resource){ redirect_to after_sign_out_path_for(resource_name) }
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,14 @@
|
||||||
|
class DeletionWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options queue: :deletion
|
||||||
|
|
||||||
|
# @param resource_id [Integer] user id passed from Devise
|
||||||
|
def perform(resource_id)
|
||||||
|
begin
|
||||||
|
User.find(resource_id).destroy!
|
||||||
|
rescue => e
|
||||||
|
Rails.logger.error "failed to delete user: #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -46,7 +46,7 @@ Rails.application.routes.draw do
|
||||||
get '/settings/account' => 'devise/registrations#edit', as: :edit_user_registration
|
get '/settings/account' => 'devise/registrations#edit', as: :edit_user_registration
|
||||||
patch '/settings/account' => 'devise/registrations#update', as: :update_user_registration
|
patch '/settings/account' => 'devise/registrations#update', as: :update_user_registration
|
||||||
put '/settings/account' => 'devise/registrations#update'
|
put '/settings/account' => 'devise/registrations#update'
|
||||||
delete '/settings/account' => 'devise/registrations#destroy'
|
delete '/settings/account' => 'user/registrations#destroy'
|
||||||
end
|
end
|
||||||
|
|
||||||
match '/settings/profile', to: 'user#edit', via: 'get', as: :edit_user_profile
|
match '/settings/profile', to: 'user#edit', via: 'get', as: :edit_user_profile
|
||||||
|
|
|
@ -8,4 +8,5 @@ production:
|
||||||
:queues:
|
:queues:
|
||||||
- share
|
- share
|
||||||
- paperclip
|
- paperclip
|
||||||
- mailer
|
- mailer
|
||||||
|
- deletion
|
||||||
|
|
Loading…
Reference in New Issue