diff --git a/lib/registration.rb b/lib/registration.rb index 79230d88f317fdc3a68cf612d0caa2d5db121977..e5db85ec22ec04a7e8e0029fa26ac6ec61e962cb 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -34,10 +34,11 @@ class Registration class Activation def self.for(customer, tel) + jid = ProxiedJID.new(customer.jid).unproxied if customer.active? Finish.new(customer, tel) - elsif CONFIG[:approved_domains].key?(customer.jid.domain.to_sym) - credit_to = CONFIG[:approved_domains][customer.jid.domain.to_sym] + elsif CONFIG[:approved_domains].key?(jid.domain.to_sym) + credit_to = CONFIG[:approved_domains][jid.domain.to_sym] Allow.new(customer, tel, credit_to) else new(customer, tel) diff --git a/test/test_registration.rb b/test/test_registration.rb index f76cb4dfb2bf92365aa6f210dead795d551680bb..06ee38ab314259536b359c5414d857b4bc920186 100644 --- a/test/test_registration.rb +++ b/test/test_registration.rb @@ -55,12 +55,15 @@ class RegistrationTest < Minitest::Test def test_for_not_activated_approved sgx = OpenStruct.new(registered?: false) web_manager = TelSelections.new(redis: FakeRedis.new) - web_manager.set("test@approved.example.com", "+15555550000") + web_manager.set("test\\40approved.example.com@component", "+15555550000") iq = Blather::Stanza::Iq::Command.new iq.from = "test@approved.example.com" result = execute_command(iq) do Registration.for( - customer(sgx: sgx, jid: Blather::JID.new("test@approved.example.com")), + customer( + sgx: sgx, + jid: Blather::JID.new("test\\40approved.example.com@component") + ), web_manager ) end