Change summary
lib/registration.rb | 11 +++++++++++
1 file changed, 11 insertions(+)
Detailed changes
@@ -41,6 +41,13 @@ class Registration
end
end
+ def self.guard_onboarding_subaccounts(customer)
+ customer_domain = ProxiedJID.new(customer.jid).domain
+ return unless customer_domain == CONFIG[:onboarding_domain]
+
+ raise "Please create a new Jabber ID before creating a subaccount."
+ end
+
class Registered
def self.for(customer, tel)
jid = ProxiedJID.new(customer.jid).unproxied
@@ -139,6 +146,8 @@ class Registration
end
def save_customer_plan(iq, code)
+ Registration.guard_onboarding_subaccounts(@customer)
+
ParentCodeRepo.new(redis: REDIS, db: DB).find(code).then do |parent|
plan = Plan.for_registration(iq.form.field("plan_name").value.to_s)
@customer = @customer.with_plan(plan.name, parent_customer_id: parent)
@@ -573,6 +582,8 @@ class Registration
end
def set_parent(parent_customer_id)
+ Registration.guard_onboarding_subaccounts(@customer)
+
@customer = @customer.with_plan(
@customer.plan_name,
parent_customer_id: parent_customer_id