Module: ZuoraConnect::Authenticate
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/zuora_connect/authenticate.rb
Overview
Methods for authenticating and setting the app instance for the current user
Instance Method Summary collapse
Instance Method Details
#setup_instance_via_dev_mode ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/concerns/zuora_connect/authenticate.rb', line 8 def setup_instance_via_dev_mode app_instance_id = ZuoraConnect.configuration.dev_mode_appinstance session['appInstance'] = app_instance_id session["#{app_instance_id}::admin"] = ZuoraConnect.configuration.dev_mode_admin values = { id: app_instance_id, access_token: ZuoraConnect.configuration.dev_mode_user, refresh_token: ZuoraConnect.configuration.dev_mode_pass, token: ZuoraConnect.configuration.dev_mode_pass + ZuoraConnect.configuration.dev_mode_pass, api_token: ZuoraConnect.configuration.dev_mode_pass + ZuoraConnect.configuration.dev_mode_pass } @appinstance = ZuoraConnect::AppInstance.find_by(id: app_instance_id) ZuoraConnect::ZuoraUser.current_user_id = 0 zuora_org_ids = ['Zuora-Org-Ids'] || request.headers['Zuora-Org-Ids'] ZuoraConnect::ZuoraUser.current_org_ids = zuora_org_ids.split('|') if zuora_org_ids if @appinstance.blank? Apartment::Tenant.switch!('public') begin Apartment::Tenant.create(app_instance_id) rescue Apartment::TenantExists Apartment::Tenant.drop(app_instance_id) retry end @appinstance = ZuoraConnect::AppInstance.new end @appinstance.assign_attributes(values) @appinstance.save(validate: false) end |