2024-11-30 13:27:21 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2024-12-28 18:37:47 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
module Users
|
|
|
|
class RegistrationsController < Devise::RegistrationsController
|
|
|
|
clear_respond_to
|
|
|
|
respond_to :json
|
2024-12-01 14:03:06 +01:00
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
before_action :validate_captcha!, only: :create
|
2024-12-01 19:56:49 +01:00
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
def create
|
|
|
|
wedding = Wedding.create(slug: params[:slug])
|
|
|
|
unless wedding.persisted?
|
|
|
|
render json: { errors: wedding.errors.full_messages }, status: :unprocessable_entity
|
|
|
|
return
|
|
|
|
end
|
2024-12-01 14:03:06 +01:00
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
ActsAsTenant.with_tenant(wedding) do
|
|
|
|
super do |user|
|
|
|
|
wedding.destroy unless user.persisted?
|
|
|
|
end
|
2024-12-01 14:03:06 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
private
|
2024-12-01 14:03:06 +01:00
|
|
|
|
2024-12-28 18:28:28 +01:00
|
|
|
def set_tenant
|
|
|
|
set_current_tenant(nil)
|
|
|
|
end
|
2024-12-01 14:03:06 +01:00
|
|
|
end
|
2024-12-28 18:28:28 +01:00
|
|
|
end
|