Retrospring/app/controllers/user/registrations_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
Ruby
Raw Normal View History

2024-08-08 20:53:37 -07:00
# frozen_string_literal: true
class User::RegistrationsController < Devise::RegistrationsController
before_action :redirect_if_registrations_disabled!, only: %w[create new] # rubocop:disable Rails/LexicallyScopedActionFilter
2024-08-08 20:53:37 -07:00
2020-05-22 13:29:22 -07:00
def create
2020-05-23 07:49:03 -07:00
if captcha_valid?
2020-05-22 13:29:22 -07:00
super
else
2024-08-08 20:53:37 -07:00
respond_with_navigational(resource) { redirect_to new_user_registration_path }
2020-05-22 13:29:22 -07:00
end
end
def destroy
if resource.export_processing
flash[:error] = t(".export_pending")
redirect_to edit_user_registration_path
return
end
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
resource.destroy
set_flash_message :notice, :destroyed if is_flashing_format?
yield resource if block_given?
2024-08-08 20:53:37 -07:00
respond_with_navigational(resource) { redirect_to after_sign_out_path_for(resource_name) }
end
2020-05-23 07:49:03 -07:00
private
def captcha_valid?
# If the captcha isn't enabled, treat it as being correct
return true unless APP_CONFIG.dig(:hcaptcha, :enabled)
verify_hcaptcha
end
2024-08-08 20:53:37 -07:00
def redirect_if_registrations_disabled!
redirect_to root_path unless Retrospring::Config.registrations_enabled?
2024-08-08 20:53:37 -07:00
end
end