2015-07-14 16:44:35 -07:00
|
|
|
class User::RegistrationsController < Devise::RegistrationsController
|
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
|
|
|
|
respond_with_navigational(resource){ redirect_to new_user_registration_path }
|
|
|
|
end
|
|
|
|
end
|
2015-07-14 16:44:35 -07:00
|
|
|
|
|
|
|
def destroy
|
2022-07-14 14:40:25 -07:00
|
|
|
if resource.export_processing
|
|
|
|
flash[:error] = t(".export_pending")
|
|
|
|
redirect_to edit_user_registration_path
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-07-14 16:44:35 -07:00
|
|
|
Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
|
2022-02-04 12:09:43 -08:00
|
|
|
resource.destroy
|
2015-07-14 16:44:35 -07:00
|
|
|
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
|
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
|
2015-07-14 16:44:35 -07:00
|
|
|
end
|