mno-enterprise-api 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +8 -0
  3. data/app/controllers/mno_enterprise/admin/invoices_controller.rb +18 -0
  4. data/app/controllers/mno_enterprise/impersonate_controller.rb +5 -1
  5. data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +9 -0
  6. data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +10 -4
  7. data/app/controllers/mno_enterprise/jpi/v1/audit_events_controller.rb +28 -0
  8. data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +1 -1
  9. data/app/controllers/mno_enterprise/webhook/events_controller.rb +7 -0
  10. data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +26 -25
  11. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +1 -1
  12. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.csv.erb +14 -0
  13. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +1 -0
  14. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -1
  15. data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +1 -0
  16. data/app/views/mno_enterprise/jpi/v1/audit_events/_audit_event.json.jbuilder +5 -0
  17. data/app/views/mno_enterprise/jpi/v1/audit_events/index.csv.erb +12 -0
  18. data/app/views/mno_enterprise/jpi/v1/audit_events/index.json.jbuilder +4 -0
  19. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +1 -1
  20. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -1
  21. data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +3 -1
  22. data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +10 -1
  23. data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +1 -1
  24. data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +1 -1
  25. data/config/routes.rb +16 -5
  26. data/lib/mno_enterprise/audit_events_listener.rb +11 -6
  27. data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +6 -1
  28. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +9 -10
  29. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb +6 -3
  30. data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +20 -8
  31. data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +12 -0
  32. data/lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb +13 -0
  33. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +2 -0
  34. data/lib/mno_enterprise/concerns/controllers/webhook/events_controller.rb +22 -0
  35. data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +12 -3
  36. data/lib/mno_enterprise/event_logger.rb +2 -2
  37. data/lib/mno_enterprise/intercom_events_listener.rb +25 -30
  38. data/spec/controllers/mno_enterprise/admin/invoices_controller_spec.rb +38 -0
  39. data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +6 -0
  40. data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +9 -0
  41. data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +3 -2
  42. data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +2 -1
  43. data/spec/controllers/mno_enterprise/jpi/v1/audit_events_controller_spec.rb +49 -0
  44. data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +16 -0
  45. data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +124 -89
  46. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +83 -36
  47. data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +18 -3
  48. data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +3 -3
  49. data/spec/controllers/mno_enterprise/provision_controller_spec.rb +2 -2
  50. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
  51. data/spec/lib/mno_enterprise/audit_events_listener_spec.rb +11 -0
  52. data/spec/lib/mno_enterprise/intercom_events_listener_spec.rb +74 -31
  53. data/spec/routing/devise/registrations_routing_spec.rb +43 -6
  54. data/spec/routing/mno_enterprise/admin/invoices_controller_routing_spec.rb +11 -0
  55. data/spec/routing/mno_enterprise/impersonate_controller_routing_spec.rb +30 -4
  56. data/spec/routing/mno_enterprise/jpi/v1/audit_events_controller_routing_spec.rb +11 -0
  57. metadata +20 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4af564651978ad7e0b8cbfc14396527b4f2ae32
4
- data.tar.gz: bac51a82bde96469c7e137de592b14e71cee1797
3
+ metadata.gz: 0d1fc05e6d511ddaa9c90ac0eadcfa98f34164be
4
+ data.tar.gz: 7cd5ece7aef6ec8bedadb102135c9e1aae7de800
5
5
  SHA512:
6
- metadata.gz: d401dac86e28a8ea2a2c2ec7a8abcc359a11474991172525fe52d8d6fead4cbd29664a3ef7ca1cc9bd550d7f960a0d8fc0c8674f832e725dc2584848e7ab22f3
7
- data.tar.gz: e2a50c14be1666f8595b1e007848808ff01ca7eaaa1a696369c1e198a88ccb7bdf776cb60d875f1c8e2bb2f9dd3fa54956e038108fce16b445126fd13124b5e3
6
+ metadata.gz: e50da83dcdacab9f7e2a4c51a538a00e885a4360c5bb4c40335f635e357c8e67474638c7b4fffaea4f8b13be69ef7a577173d22a3722f305ac39f5290f7aa386
7
+ data.tar.gz: 04d2713f52f2bdb25d6605b8a9243e3b313e661aebf457cf4af81976ab9d3d74ba30f7952cd054eb6181d94d261dbb9da29713d24369fc6302975e795691c72f
@@ -11,8 +11,16 @@ angular.module('mnoEnterprise.configuration', [])
11
11
  .constant('PRICING_CONFIG', <%= Hash(Settings.pricing).to_json %>)
12
12
  .constant('DOCK_CONFIG', <%= Hash(Settings.dock).to_json %>)
13
13
  .constant('DEVELOPER_SECTION_CONFIG', <%= Hash(Settings.developer).to_json %>)
14
+ .constant('ONBOARDING_WIZARD_CONFIG', <%= Hash(Settings.onboarding_wizard).to_json %>)
14
15
  .constant('REVIEWS_CONFIG', <%= Hash(Settings.reviews).to_json %>)
16
+ .constant('QUESTIONS_CONFIG', <%= Hash(Settings.questions).to_json %>)
15
17
  .constant('MARKETPLACE_CONFIG', <%= Hash(Settings.marketplace).to_json %>)
18
+ .constant('ADMIN_PANEL_CONFIG', <%= Hash(Settings.admin_panel).to_json %>)
19
+ .constant('PAYMENT_CONFIG', <%= Hash(Settings.payment).to_json %>)
20
+ .constant('ORGANIZATION_MANAGEMENT', <%= Hash(Settings.organization_management).to_json %>)
21
+ .constant('USER_MANAGEMENT', <%= Hash(Settings.user_management).to_json %>)
22
+ .constant('AUDIT_LOG', <%= Hash(Settings.audit_log).to_json %>)
16
23
  .constant('GOOGLE_TAG_CONTAINER_ID', <%= MnoEnterprise.google_tag_container.to_json %>)
17
24
  .constant('INTERCOM_ID', <%= MnoEnterprise.intercom_app_id.to_json %>)
18
25
  .constant('APP_NAME', <%= MnoEnterprise.app_name.to_json %>)
26
+ .constant('URL_CONFIG', <%= Hash(Settings.url_config).to_json %>)
@@ -0,0 +1,18 @@
1
+ module MnoEnterprise
2
+ class Admin::InvoicesController < MnoEnterprise::Jpi::V1::Admin::BaseResourceController
3
+ # GET /mnoe/invoices/201504-NU4
4
+ def show
5
+ @invoice = MnoEnterprise::Invoice.where(slug: params[:id].upcase).reload.first
6
+
7
+ respond_to do |format|
8
+ if @invoice
9
+ filename = "Invoice - #{@invoice.slug}.pdf"
10
+ pdf_view = MnoEnterprise::InvoicePdf.new(@invoice).render
11
+ format.html { send_data pdf_view, filename: filename, type: "application/pdf", disposition: 'inline' }
12
+ else
13
+ format.html { redirect_to root_path, alert: 'Sorry, the page requested could not be displayed' }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -15,7 +15,11 @@ module MnoEnterprise
15
15
  else
16
16
  flash[:notice] = "User doesn't exist"
17
17
  end
18
- redirect_to mnoe_home_path
18
+
19
+ path = mnoe_home_path
20
+ path = add_param_to_fragment(path, 'dhbRefId', params[:dhbRefId]) if params[:dhbRefId].present?
21
+
22
+ redirect_to path
19
23
  end
20
24
 
21
25
  # Revert the user impersonation
@@ -1,3 +1,4 @@
1
+ require 'csv'
1
2
  module MnoEnterprise
2
3
  class Jpi::V1::Admin::AuditEventsController < Jpi::V1::Admin::BaseResourceController
3
4
 
@@ -11,6 +12,14 @@ module MnoEnterprise
11
12
  @audit_events = @audit_events.all.fetch
12
13
 
13
14
  response.headers['X-Total-Count'] = @audit_events.metadata[:pagination][:count]
15
+
16
+ respond_to do |format|
17
+ format.json
18
+ format.csv do
19
+ headers['Content-Disposition'] = 'attachment; filename="audit-log.csv"'
20
+ headers['Content-Type'] ||= 'text/csv'
21
+ end
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -29,7 +29,6 @@ module MnoEnterprise
29
29
  # POST /mnoe/jpi/v1/admin/users
30
30
  def create
31
31
  @user = MnoEnterprise::User.build(user_create_params)
32
- @user.admin_role = params[:user][:admin_role].presence
33
32
 
34
33
  if @user.save
35
34
  render :show
@@ -40,6 +39,7 @@ module MnoEnterprise
40
39
 
41
40
  # PATCH /mnoe/jpi/v1/admin/users/:id
42
41
  def update
42
+ # TODO: replace with authorize/ability
43
43
  if current_user.admin_role == "admin"
44
44
  @user = MnoEnterprise::User.find(params[:id])
45
45
  @user.update(user_params)
@@ -79,9 +79,15 @@ module MnoEnterprise
79
79
  end
80
80
 
81
81
  def user_create_params
82
- params.require(:user).permit(:name, :surname, :email, :phone).merge(
83
- password: 'Password1',
84
- confirmed_at: Time.zone.now
82
+ attrs = [:name, :surname, :email, :phone]
83
+
84
+ # TODO: replace with authorize/ability
85
+ if current_user.admin_role == "admin"
86
+ attrs << :admin_role
87
+ end
88
+
89
+ params.require(:user).permit(attrs).merge(
90
+ password: Devise.friendly_token.first(12)
85
91
  )
86
92
  end
87
93
  end
@@ -0,0 +1,28 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::AuditEventsController < Jpi::V1::BaseResourceController
3
+
4
+ # GET /mnoe/jpi/v1/admin/audit_events
5
+ def index
6
+ @organization = MnoEnterprise::Organization.find(params.require(:organization_id))
7
+
8
+ authorize! :administrate, @organization
9
+
10
+ @audit_events = MnoEnterprise::AuditEvent.where(organization_id: @organization.id)
11
+ @audit_events = @audit_events.limit(params[:limit]) if params[:limit]
12
+ @audit_events = @audit_events.skip(params[:offset]) if params[:offset]
13
+ @audit_events = @audit_events.order_by(params[:order_by]) if params[:order_by]
14
+ @audit_events = @audit_events.where(params[:where]) if params[:where]
15
+ @audit_events = @audit_events.all.fetch
16
+
17
+ response.headers['X-Total-Count'] = @audit_events.metadata[:pagination][:count]
18
+
19
+ respond_to do |format|
20
+ format.json
21
+ format.csv do
22
+ headers['Content-Disposition'] = 'attachment; filename="audit-log.csv"'
23
+ headers['Content-Type'] ||= 'text/csv'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,7 +1,7 @@
1
1
  module MnoEnterprise
2
2
  class Jpi::V1::BaseResourceController < ApplicationController
3
3
  before_filter :check_authorization
4
-
4
+
5
5
  protected
6
6
 
7
7
  def timestamp
@@ -0,0 +1,7 @@
1
+ module MnoEnterprise
2
+ # The object received on this controller looks like Parameters: {"event"=>"", "object"=>{}, "metadata"={}}
3
+ class Webhook::EventsController < ApplicationController
4
+ include MnoEnterprise::Concerns::Controllers::Webhook::EventsController
5
+ # You can easily overwrite/extend this concern by inserting the code here
6
+ end
7
+ end
@@ -1,32 +1,33 @@
1
- .banners.promo.dark.darkblue.confirmation-lounge
1
+ .registration
2
2
  .container
3
3
  .row
4
- .col-md-8.col-md-offset-2
5
- .row
6
- .align-center
7
- %i.fa.fa-envelope
8
- %h4= t('mno_enterprise.auth.confirmations.lounge.title')
9
- %h5= t('mno_enterprise.auth.confirmations.lounge.subtitle')
10
-
4
+ .login-box-wrapper
5
+ .login-box-title
6
+ %h2= t('mno_enterprise.auth.confirmations.lounge.title')
7
+ .login-box
8
+ .brand-logo
9
+ %form
10
+ %label{ :style => "font-weight: normal;"}= t('mno_enterprise.auth.confirmations.lounge.subtitle')
11
11
  %div{ 'ng-init' => "email = '#{@resource.email}'"}
12
- = form_for(@resource, :as => resource_name, :url => mno_enterprise.user_confirmation_path, :html => { 'name' => 'form', :class => 'dark form-horizontal', :autocomplete => "off" }) do |f|
12
+ = form_for(@resource, :as => resource_name, :url => mno_enterprise.user_confirmation_path, :html => { 'name' => 'form', class: 'form-horizontal', :autocomplete => "off" }) do |f|
13
+
13
14
  - unless devise_error_messages!.empty?
14
- %div
15
+ .row
15
16
  .alert.alert-error
16
- %button.close{ 'data-dismiss' => "alert" } ×
17
+ %button.close ×
17
18
  = devise_error_messages!
18
19
  .spacer2
19
- .form-group
20
- .col-sm-6.col-sm-offset-2
21
- .input-prepend
22
- = f.email_field :email, :placeholder => "Email", :required => true, 'ng-model' => 'email', :class => 'input-xlarge'
23
- .col-sm-2
24
- %button{ :class => "btn btn-lg btn-warning", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'form.$invalid', 'ng-hide' => 'hasClicked' }= t('mno_enterprise.auth.confirmations.lounge.resend')
25
- %img{ class: 'loader-sm', 'ng-src' => asset_path('mno_enterprise/loader-32x32-bg-main.gif'), 'ng-show' => 'hasClicked' }
26
-
27
- .spacer2
28
- .row
29
- .col-md-12
30
- .align-center
31
- %h5
32
- = t('mno_enterprise.auth.confirmations.lounge.support_tip_html', email: mail_to(support_email, t('mno_enterprise.auth.confirmations.lounge.support_team'), subject: t('mno_enterprise.auth.confirmations.lounge.support_email_subject')))
20
+ %hr
21
+ .form-horizontal
22
+ .row
23
+ .text-center
24
+ .col-sm-12
25
+ %label{ :style => "font-weight: normal;"}= t('mno_enterprise.auth.confirmations.lounge.resend.description')
26
+ .col-sm-12
27
+ = f.email_field :email, :placeholder => "Email", :required => true, 'ng-model' => 'email', :class => 'form-control'
28
+ %br
29
+ .row
30
+ .col-sm-12
31
+ .text-center
32
+ %button{ :class => "btn btn-warning", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'form.$invalid', 'ng-hide' => 'hasClicked' }= t('.resend.button')
33
+ %img.ng-hide{ 'ng-src' => asset_path('mno_enterprise/loader-32x32-bg-inverse.gif'), 'ng-show' => 'hasClicked' }
@@ -1,4 +1,4 @@
1
- json.extract! audit_event, :id, :key, :user_id, :description, :created_at, :user
1
+ json.extract! audit_event, :id, :key, :user_id, :description, :created_at, :user, :organization
2
2
 
3
3
  if audit_event.formatted_details.present?
4
4
  json.details audit_event.formatted_details
@@ -0,0 +1,14 @@
1
+ <%- headers = ['Date', 'User', 'User email', 'Organization', 'Organization Name', 'Action', 'Description', 'Details'] -%>
2
+ <%= CSV.generate_line headers -%>
3
+ <%- @audit_events.each do |event| -%>
4
+ <%= CSV.generate_line([
5
+ event.created_at,
6
+ event.user[:name],
7
+ event.user[:email],
8
+ event.organization_id,
9
+ event.organization[:name],
10
+ event.key,
11
+ event.description,
12
+ event.formatted_details.present? ? %{#{event.formatted_details}} : event.metadata
13
+ ]).html_safe -%>
14
+ <%- end -%>
@@ -4,5 +4,6 @@ json.invoices do
4
4
  json.ended_at invoice.ended_at
5
5
  json.amount AccountingjsSerializer.serialize(invoice.total_due)
6
6
  json.paid invoice.paid?
7
+ json.link mno_enterprise.admin_invoice_path(invoice.slug)
7
8
  end
8
9
  end
@@ -1 +1 @@
1
- json.extract! organization, :id, :name, :uid, :soa_enabled, :created_at
1
+ json.extract! organization, :id, :name, :uid, :soa_enabled, :created_at, :account_frozen
@@ -5,6 +5,7 @@ json.user do
5
5
  json.id org.id
6
6
  json.uid org.uid
7
7
  json.name org.name
8
+ json.account_frozen org.account_frozen
8
9
  json.created_at org.created_at
9
10
  end
10
11
  end
@@ -0,0 +1,5 @@
1
+ json.extract! audit_event, :id, :key, :user_id, :description, :created_at, :user
2
+
3
+ if audit_event.formatted_details.present?
4
+ json.details audit_event.formatted_details
5
+ end
@@ -0,0 +1,12 @@
1
+ <%- headers = ['Date', 'User', 'User email', 'Action', 'Description', 'Details'] -%>
2
+ <%= CSV.generate_line headers -%>
3
+ <%- @audit_events.each do |event| -%>
4
+ <%= CSV.generate_line([
5
+ event.created_at,
6
+ event.user[:name],
7
+ event.user[:email],
8
+ event.key,
9
+ event.description,
10
+ event.formatted_details.present? ? %{#{event.formatted_details}} : event.metadata
11
+ ]).html_safe -%>
12
+ <%- end -%>
@@ -0,0 +1,4 @@
1
+ json.audit_events do
2
+ json.array! @audit_events, partial: 'audit_event', as: :audit_event
3
+ end
4
+ json.metadata @audit_events.metadata
@@ -27,7 +27,7 @@ json.cache! ['v1', @user.cache_key] do
27
27
  # Embed association if user is persisted
28
28
  if @user.id
29
29
  json.organizations do
30
- json.array! (@user.organizations || []) do |o|
30
+ json.array! (@user.organizations.active || []) do |o|
31
31
  json.id o.id
32
32
  json.uid o.uid
33
33
  json.name o.name
@@ -1,4 +1,4 @@
1
1
  json.ignore_nil!
2
2
  json.extract! kpi, :id, :element_watched, :endpoint, :source, :targets, :settings, :extra_watchables, :extra_params
3
3
 
4
- json.alerts kpi.alerts, partial: 'mno_enterprise/jpi/v1/impac/alerts/alert', as: :alert
4
+ json.alerts kpi.alerts, partial: 'mno_enterprise/jpi/v1/impac/alerts/alert', as: :alert if kpi.alerts.any?
@@ -1,6 +1,8 @@
1
1
  json.id widget.id
2
2
  json.name widget.name
3
- json.category widget.widget_category
3
+ json.endpoint (widget.endpoint || widget.widget_category)
4
4
  json.width widget.width
5
5
  json.metadata widget.settings
6
6
  json.owner widget.owner
7
+
8
+ json.kpis widget.kpis, partial: 'mno_enterprise/jpi/v1/impac/kpis/kpi', as: :kpi
@@ -1,7 +1,9 @@
1
1
  json.extract! app, :id, :nid, :name, :stack, :key_benefits, :categories, :tags, :tiny_description,
2
- :testimonials, :pictures, :pricing_plans, :rank
2
+ :testimonials, :pictures, :pricing_plans, :rank, :support_url, :key_workflows, :key_features
3
3
 
4
4
  json.description markdown(app.sanitized_description)
5
+ json.known_limitations markdown(app.known_limitations)
6
+ json.getting_started markdown(app.getting_started)
5
7
 
6
8
  json.is_responsive app.responsive?
7
9
  json.is_star_ready app.star_ready?
@@ -11,8 +13,15 @@ json.single_billing app.single_billing?
11
13
  json.multi_instantiable app.multi_instantiable
12
14
  json.subcategories app.subcategories
13
15
  json.average_rating app.average_rating
16
+ json.add_on app.add_on?
14
17
  json.running_instances_count app.running_instances_count
15
18
 
19
+ json.shared_entities do
20
+ json.array! app.shared_entities do |shared_entity|
21
+ json.extract! shared_entity, :shared_entity_nid, :shared_entity_name, :write, :read
22
+ end
23
+ end if app.shared_entities.any?
24
+
16
25
  if app.logo
17
26
  json.logo app.logo.to_s
18
27
  end
@@ -1,4 +1,4 @@
1
- json.extract! organization, :id, :name, :soa_enabled, :payment_restriction #, :current_support_plan
1
+ json.extract! organization, :id, :name, :soa_enabled, :payment_restriction, :account_frozen #, :current_support_plan
2
2
  # json.show_new_db_features !!organization.get_meta_data(:show_new_db_features)
3
3
  # if organization.support_plan
4
4
  # json.custom_training_credits organization.support_plan.custom_training_credits
@@ -4,7 +4,7 @@
4
4
  .row
5
5
  .col-md-6.text-center.col-md-offset-3
6
6
  %h3= t('.you_are_redirected')
7
- = image_tag('mno_enterprise/maestrano/logo-whitebg.png')
7
+ = image_tag(main_logo_white_bg_path)
8
8
 
9
9
  .spacer1
10
10
 
@@ -26,20 +26,27 @@ MnoEnterprise::Engine.routes.draw do
26
26
  end
27
27
  end
28
28
 
29
+ # Invoices
30
+ namespace :admin do
31
+ resources :invoices, only: [:show], constraints: { id: /[\w\-]+/ }
32
+ end
29
33
 
30
- get "/impersonate/user/:user_id", to: "impersonate#create", as: :impersonate_user
31
- get "/impersonate/revert", to: "impersonate#destroy", as: :revert_impersonate_user
32
-
34
+ unless Settings.try(:admin_panel).try(:impersonation).try(:disabled)
35
+ get "/impersonate/user/:user_id", to: "impersonate#create", as: :impersonate_user
36
+ get "/impersonate/revert", to: "impersonate#destroy", as: :revert_impersonate_user
37
+ end
33
38
 
34
39
  #============================================================
35
40
  # Devise/User Configuration
36
41
  #============================================================
37
42
  # Main devise configuration
43
+ skipped_devise_modules = [:omniauth_callbacks]
44
+ skipped_devise_modules << :registrations if Settings.try(:devise).try(:registration).try(:disabled)
38
45
  devise_for :users, {
39
46
  class_name: "MnoEnterprise::User",
40
47
  module: :devise,
41
48
  path_prefix: 'auth',
42
- skip: :omniauth_callbacks,
49
+ skip: skipped_devise_modules,
43
50
  controllers: {
44
51
  confirmations: "mno_enterprise/auth/confirmations",
45
52
  omniauth_callbacks: "mno_enterprise/auth/omniauth_callbacks",
@@ -84,6 +91,8 @@ MnoEnterprise::Engine.routes.draw do
84
91
  get :sync
85
92
  end
86
93
  end
94
+ # Maestrano-hub events
95
+ resources :events, only: [:create]
87
96
  end
88
97
 
89
98
  #============================================================
@@ -95,7 +104,7 @@ MnoEnterprise::Engine.routes.draw do
95
104
  member do
96
105
  %i(app_reviews app_feedbacks app_comments app_questions app_answers).each do |name|
97
106
  resources name, except: [:new, :edit], param: :review_id
98
- end
107
+ end
99
108
  end
100
109
  end
101
110
  resource :current_user, only: [:show, :update] do
@@ -125,6 +134,8 @@ MnoEnterprise::Engine.routes.draw do
125
134
  end
126
135
 
127
136
  resources :app_instances_sync, only: [:create, :index]
137
+
138
+ resources :audit_events, only: [:index]
128
139
  end
129
140
 
130
141
  resources :deletion_requests, only: [:show, :create, :destroy] do
@@ -8,21 +8,26 @@ module MnoEnterprise
8
8
  basic_auth MnoEnterprise.tenant_id, MnoEnterprise.tenant_key
9
9
 
10
10
  def info(key, current_user_id, description, subject_type, subject_id, metadata)
11
- self.class.post('', body: {
11
+ organization_id = if (subject_type == 'MnoEnterprise::Organization') then
12
+ subject_id
13
+ elsif metadata.is_a?(Hash)
14
+ metadata[:organization_id].presence
15
+ end
16
+ body = {
12
17
  data: {
13
18
  key: key,
14
19
  user_id: current_user_id,
15
20
  description: description,
16
21
  metadata: metadata,
17
22
  subject_type: subject_type,
18
- subject_id: subject_id
19
- }})
23
+ subject_id: subject_id,
24
+ }
25
+ }
26
+ body[:data][:organization_id] = organization_id if organization_id
27
+ self.class.post('', body: body)
20
28
  rescue Net::ReadTimeout
21
29
  # Meant to fail
22
30
  end
23
-
24
31
  end
25
-
26
-
27
32
  end
28
33