Module: Devise::Models::KillbillAuthenticatable::ClassMethods
- Defined in:
- app/models/kaui/killbill_authenticatable.rb
Instance Method Summary collapse
-
#find_for_killbill_authentication(kb_username, kb_password, api_key, api_secret) ⇒ Object
Invoked by the KillbillAuthenticatable strategy to lookup the user before attempting authentication.
Instance Method Details
#find_for_killbill_authentication(kb_username, kb_password, api_key, api_secret) ⇒ Object
Invoked by the KillbillAuthenticatable strategy to lookup the user before attempting authentication
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/kaui/killbill_authenticatable.rb', line 27 def find_for_killbill_authentication(kb_username, kb_password, api_key, api_secret) kb_tenant_id = nil # Only in the Multi-Tenancy usecase if api_key.present? tenant = KillBillClient::Model::Tenant.find_by_api_key api_key, { :username => kb_username, :password => kb_password, :api_key => api_key, :api_secret => api_secret } kb_tenant_id = tenant.tenant_id if tenant.present? end find_for_authentication(:kb_tenant_id => kb_tenant_id, :kb_username => kb_username) || new(:kb_tenant_id => kb_tenant_id, :kb_username => kb_username) rescue KillBillClient::API::Unauthorized => e # Multi-Tenancy was enabled, but the tenant_id couldn't be retrieved because of bad credentials nil end |