Module: Kaui

Defined in:
app/models/kaui/killbill_registerable.rb,
lib/kaui.rb,
lib/kaui/engine.rb,
lib/kaui/version.rb,
app/models/kaui/tag.rb,
app/models/kaui/base.rb,
app/models/kaui/user.rb,
app/models/kaui/admin.rb,
app/models/kaui/bundle.rb,
app/models/kaui/credit.rb,
app/models/kaui/refund.rb,
app/models/kaui/tenant.rb,
app/models/kaui/ability.rb,
app/models/kaui/account.rb,
app/models/kaui/catalog.rb,
app/models/kaui/invoice.rb,
app/models/kaui/overdue.rb,
app/models/kaui/payment.rb,
app/models/kaui/audit_log.rb,
app/models/kaui/user_role.rb,
app/models/kaui/chargeback.rb,
app/models/kaui/simple_plan.rb,
app/models/kaui/transaction.rb,
app/helpers/kaui/date_helper.rb,
app/helpers/kaui/home_helper.rb,
app/helpers/kaui/uuid_helper.rb,
app/models/kaui/admin_tenant.rb,
app/models/kaui/allowed_user.rb,
app/models/kaui/custom_field.rb,
app/models/kaui/invoice_item.rb,
app/models/kaui/subscription.rb,
app/helpers/kaui/money_helper.rb,
app/models/kaui/account_email.rb,
app/models/kaui/payment_state.rb,
app/models/kaui/rails_methods.rb,
app/helpers/kaui/locale_helper.rb,
app/helpers/kaui/object_helper.rb,
app/helpers/kaui/plugin_helper.rb,
app/models/kaui/payment_method.rb,
app/models/kaui/tag_definition.rb,
app/helpers/kaui/account_helper.rb,
app/helpers/kaui/payment_helper.rb,
app/models/kaui/invoice_payment.rb,
app/models/kaui/role_definition.rb,
app/models/kaui/account_timeline.rb,
app/helpers/kaui/us_states_helper.rb,
app/models/kaui/application_record.rb,
app/helpers/kaui/application_helper.rb,
app/helpers/kaui/permissions_helper.rb,
app/models/kaui/allowed_user_tenant.rb,
app/controllers/kaui/home_controller.rb,
app/controllers/kaui/tags_controller.rb,
app/helpers/kaui/subscription_helper.rb,
app/controllers/kaui/admin_controller.rb,
app/controllers/kaui/queues_controller.rb,
app/helpers/kaui/payment_method_helper.rb,
app/controllers/kaui/bundles_controller.rb,
app/controllers/kaui/charges_controller.rb,
app/controllers/kaui/credits_controller.rb,
app/controllers/kaui/refunds_controller.rb,
app/controllers/kaui/tenants_controller.rb,
app/controllers/kaui/accounts_controller.rb,
app/controllers/kaui/invoices_controller.rb,
app/controllers/kaui/payments_controller.rb,
app/controllers/kaui/sessions_controller.rb,
app/models/kaui/killbill_authenticatable.rb,
app/controllers/kaui/audit_logs_controller.rb,
app/controllers/kaui/bundle_tags_controller.rb,
app/controllers/kaui/chargebacks_controller.rb,
app/controllers/kaui/engine_controller_util.rb,
app/controllers/kaui/login_proxy_controller.rb,
app/controllers/kaui/account_tags_controller.rb,
app/controllers/kaui/invoice_tags_controller.rb,
app/controllers/kaui/transactions_controller.rb,
app/controllers/kaui/admin_tenants_controller.rb,
app/controllers/kaui/custom_fields_controller.rb,
app/controllers/kaui/invoice_items_controller.rb,
app/controllers/kaui/registrations_controller.rb,
app/controllers/kaui/subscriptions_controller.rb,
lib/generators/kaui/install/install_generator.rb,
app/controllers/kaui/account_emails_controller.rb,
app/controllers/kaui/payment_methods_controller.rb,
app/controllers/kaui/tag_definitions_controller.rb,
app/controllers/kaui/account_children_controller.rb,
app/controllers/kaui/role_definitions_controller.rb,
app/controllers/kaui/account_timelines_controller.rb,
app/controllers/kaui/admin_allowed_users_controller.rb,
app/controllers/kaui/account_custom_fields_controller.rb

Overview

Hack for Zeitwerk

Defined Under Namespace

Modules: AccountHelper, ApplicationHelper, DateHelper, EngineControllerUtil, HomeHelper, KillbillAuthenticatable, KillbillRegisterable, LocaleHelper, MoneyHelper, ObjectHelper, PaymentHelper, PaymentMethodHelper, PaymentState, PermissionsHelper, PluginHelper, RailsMethods, SubscriptionHelper, UsStatesHelper, UuidHelper Classes: Ability, Account, AccountChildrenController, AccountCustomFieldsController, AccountEmail, AccountEmailsController, AccountTagsController, AccountTimeline, AccountTimelinesController, AccountsController, Admin, AdminAllowedUsersController, AdminController, AdminTenant, AdminTenantsController, AllowedUser, AllowedUserTenant, ApplicationRecord, AuditLog, AuditLogsController, Base, Bundle, BundleTagsController, BundlesController, Catalog, Chargeback, ChargebacksController, ChargesController, Credit, CreditsController, CustomField, CustomFieldsController, Engine, EngineController, HomeController, InstallGenerator, Invoice, InvoiceItem, InvoiceItemsController, InvoicePayment, InvoiceTagsController, InvoicesController, LoginProxyController, Overdue, Payment, PaymentMethod, PaymentMethodsController, PaymentsController, QueuesController, Refund, RefundsController, RegistrationsController, RoleDefinition, RoleDefinitionsController, SessionsController, SimplePlan, Subscription, SubscriptionsController, Tag, TagDefinition, TagDefinitionsController, TagsController, Tenant, TenantsController, Transaction, TransactionsController, User, UserRole

Constant Summary collapse

VERSION =
'2.2.1'

Class Method Summary collapse

Class Method Details

.configObject



199
200
201
202
203
# File 'lib/kaui.rb', line 199

def self.config
  {
    layout: layout || 'kaui/layouts/kaui_application'
  }
end

.current_tenant_user_options(user, session) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/kaui.rb', line 184

def self.current_tenant_user_options(user, session)
  kb_tenant_id = session[:kb_tenant_id]
  user_tenant = Kaui::Tenant.find_by_kb_tenant_id(kb_tenant_id) if kb_tenant_id
  result = {
    username: user.kb_username,
    password: user.password,
    session_id: user.kb_session_id
  }
  if user_tenant
    result[:api_key] = user_tenant.api_key
    result[:api_secret] = user_tenant.api_secret
  end
  result
end

.user_assigned_valid_tenant?(user, session) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/kaui.rb', line 164

def self.user_assigned_valid_tenant?(user, session)
  #
  # If those are set in config initializer then we bypass the check
  # For multi-tenant production deployment, those should not be set!
  #
  return true if KillBillClient.api_key.present? && KillBillClient.api_secret.present?

  # Not tenant in the session, returns right away...
  return false if session[:kb_tenant_id].nil?

  # Signed-out?
  return false if user.nil?

  # If there is a kb_tenant_id in the session then we check if the user is allowed to access it
  au = Kaui::AllowedUser.find_by_kb_username(user.kb_username)
  return false if au.nil?

  au.kaui_tenants.select { |t| t.kb_tenant_id == session[:kb_tenant_id] }.first
end