Class: Kaui::EngineController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Kaui::EngineController
show all
- Includes:
- EngineControllerUtil
- Defined in:
- app/controllers/kaui/engine_controller.rb
Direct Known Subclasses
AccountChildrenController, AccountCustomFieldsController, AccountEmailsController, AccountTagsController, AccountTimelinesController, AccountsController, AdminAllowedUsersController, AdminController, AdminTenantsController, AuditLogsController, BundleTagsController, BundlesController, ChargebacksController, ChargesController, CreditsController, CustomFieldsController, HomeController, InvoiceItemsController, InvoicesController, LoginProxyController, PaymentMethodsController, PaymentsController, QueuesController, RefundsController, RoleDefinitionsController, SubscriptionsController, TagDefinitionsController, TagsController, TenantsController, TransactionsController
Constant Summary
Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary
collapse
Instance Method Details
#check_for_redirect_to_tenant_screen ⇒ Object
29
30
31
32
33
34
|
# File 'app/controllers/kaui/engine_controller.rb', line 29
def check_for_redirect_to_tenant_screen
unless Kaui.is_user_assigned_valid_tenant?(current_user, session)
session[:kb_tenant_id] = nil
redirect_to Kaui.tenant_home_path.call
end
end
|
#current_ability ⇒ Object
24
25
26
27
|
# File 'app/controllers/kaui/engine_controller.rb', line 24
def current_ability
@current_ability ||= Kaui::Ability.new(current_user)
end
|
#current_user ⇒ Object
Used for auditing purposes
20
21
22
|
# File 'app/controllers/kaui/engine_controller.rb', line 20
def current_user
super
end
|
#options_for_klient(options = {}) ⇒ Object
Common options for the Kill Bill client
10
11
12
13
14
15
16
17
|
# File 'app/controllers/kaui/engine_controller.rb', line 10
def options_for_klient(options = {})
user_tenant_options = Kaui.current_tenant_user_options(current_user, session)
user_tenant_options.merge(options)
user_tenant_options[:request_id] ||= request.request_id
user_tenant_options
end
|
#populate_account_details ⇒ Object
36
37
38
|
# File 'app/controllers/kaui/engine_controller.rb', line 36
def populate_account_details
@account ||= params[:account_id].present? ? Kaui::Account.find_by_id(params[:account_id], false, false, options_for_klient) : Kaui::Account.new
end
|
#retrieve_allowed_users_for_current_user ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/kaui/engine_controller.rb', line 48
def retrieve_allowed_users_for_current_user
tenants_for_current_user = retrieve_tenants_for_current_user
Kaui::AllowedUser.preload(:kaui_tenants).all.select do |user|
tenants_for_user = user.kaui_tenants.map(&:kb_tenant_id)
if tenants_for_user.empty?
current_user.root?
else
(tenants_for_user - tenants_for_current_user).empty?
end
end
end
|
#retrieve_tenants_for_current_user ⇒ Object
40
41
42
43
44
45
46
|
# File 'app/controllers/kaui/engine_controller.rb', line 40
def retrieve_tenants_for_current_user
if current_user.root?
Kaui::Tenant.all.map(&:kb_tenant_id)
else
Kaui::AllowedUser.preload(:kaui_tenants).find_by_kb_username(current_user.kb_username).kaui_tenants.map(&:kb_tenant_id)
end
end
|