Class: Kaui::TenantsController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::TenantsController
- Defined in:
- app/controllers/kaui/tenants_controller.rb
Constant Summary
Constants included from EngineControllerUtil
EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary collapse
Methods inherited from EngineController
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user
Instance Method Details
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/kaui/tenants_controller.rb', line 7 def index # Retrieve current user and extract allowed list of tenants allowed_user = Kaui::AllowedUser.find_by_kb_username(current_user.kb_username) @tenants = allowed_user&.kaui_tenants || [] # # If there is nothing, we check for override with KillBillClient.api_key/KillBillClient.api_secret # If there is only one, we skip the tenant screen since the choice is obvious # If not, we allow user to choose what he wants # case @tenants.size when 0 tenant = KillBillClient.api_key.nil? ? nil : KillBillClient::Model::Tenant.find_by_api_key(KillBillClient.api_key, session_id: current_user.kb_session_id) if tenant.present? select_tenant_for_tenant_id(tenant.tenant_id, tenant.external_key, nil) else redirect_to new_admin_tenant_path end when 1 # If there is only one tenant defined we skip the screen and set the tenant for the user select_tenant_for_tenant_id(@tenants[0].kb_tenant_id, @tenants[0].name, @tenants[0].id) # else jump to default view allowing to chose which tenant to pick end end |