mno-enterprise-api 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -0
- data/Rakefile +12 -0
- data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
- data/app/assets/javascripts/mno_enterprise/application.js +13 -0
- data/app/controllers/devise/password_expired_controller.rb +55 -0
- data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
- data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
- data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
- data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
- data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
- data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
- data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
- data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
- data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
- data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
- data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
- data/app/controllers/mno_enterprise/status_controller.rb +27 -0
- data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
- data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
- data/app/models/mno_enterprise/health_check.rb +16 -0
- data/app/views/devise/password_expired/show.html.haml +32 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
- data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
- data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
- data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
- data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
- data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
- data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
- data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
- data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
- data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
- data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
- data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
- data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
- data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
- data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
- data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
- data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
- data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
- data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
- data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
- data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
- data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
- data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
- data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
- data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
- data/app/views/mno_enterprise/provision/new.html.haml +4 -0
- data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
- data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
- data/config/initializers/devise.rb +273 -0
- data/config/initializers/devise_extension.rb +9 -0
- data/config/initializers/devise_log.rb +12 -0
- data/config/initializers/health_check.rb +35 -0
- data/config/initializers/main_app_version.rb +6 -0
- data/config/routes.rb +152 -0
- data/lib/mno-enterprise-api.rb +1 -0
- data/lib/mno_enterprise/api.rb +14 -0
- data/lib/mno_enterprise/api/engine.rb +9 -0
- data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
- data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
- data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
- data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
- data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
- data/lib/mno_enterprise/event_logger.rb +32 -0
- data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
- data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
- data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
- data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
- data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
- data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
- data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
- data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
- data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
- data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
- data/spec/rails_helper.rb +94 -0
- data/spec/requests/devise/authentication_spec.rb +43 -0
- data/spec/requests/devise/registration_spec.rb +64 -0
- data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
- data/spec/routing/devise/passwords_routing_spec.rb +24 -0
- data/spec/routing/devise/registrations_routing_spec.rb +16 -0
- data/spec/routing/devise/sessions_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
- data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
- data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
- data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
- data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
- data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
- data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
- data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
- data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
- data/spec/spec_helper.rb +88 -0
- metadata +402 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::MarketplaceController < ApplicationController
|
3
|
+
respond_to :json
|
4
|
+
|
5
|
+
# GET /mnoe/mnoe/jpi/v1/marketplace
|
6
|
+
def index
|
7
|
+
@apps = if MnoEnterprise.marketplace_listing
|
8
|
+
MnoEnterprise::App.where('nid.in' => MnoEnterprise.marketplace_listing).to_a
|
9
|
+
else
|
10
|
+
MnoEnterprise::App.all.to_a
|
11
|
+
end
|
12
|
+
|
13
|
+
@categories = MnoEnterprise::App.categories(@apps)
|
14
|
+
@categories.delete('Most Popular')
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /mnoe/jpi/v1/marketplace/1
|
18
|
+
def show
|
19
|
+
@app = MnoEnterprise::App.find(params[:id])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::ShoppingCartController < ApplicationController
|
3
|
+
# before_filter :authenticate_user!, except: [:apps]
|
4
|
+
# before_filter :inject_cart_and_authorize, only: [:show,:upsert_item,:remove_item,:checkout]
|
5
|
+
#
|
6
|
+
# # When a user signs in from the shopping
|
7
|
+
# # cart, the CSRF token seems to change therefore
|
8
|
+
# # preventing any POST request later on
|
9
|
+
# # TODO: We should be able to grab the new CSRF token on
|
10
|
+
# # login and inject it in angular
|
11
|
+
# skip_before_filter :verify_authenticity_token
|
12
|
+
#
|
13
|
+
# # GET /mnoe/jpi/v1/shopping_cart/apps
|
14
|
+
# # params:
|
15
|
+
# # - ensure_apps: [{ app: {id: 16 } }] (as string) -- ensure that some apps are present in the list
|
16
|
+
# def apps
|
17
|
+
# @apps = App.active.to_a
|
18
|
+
#
|
19
|
+
# if params[:ensure_apps].present?
|
20
|
+
# begin
|
21
|
+
# id_list = JSON.parse(params[:ensure_apps]).map { |h| (h['app']||{})['id'] }.compact
|
22
|
+
# @apps += App.where(id: id_list).to_a
|
23
|
+
# @apps.uniq!
|
24
|
+
# rescue
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# @apps.sort! { |a,b| a.name <=> b.name }
|
29
|
+
#
|
30
|
+
# render json: @apps.map { |a| Shopping::Cart.hash_for_app(a) }
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# # GET /mnoe/jpi/v1/shopping_cart/organizations
|
34
|
+
# def organizations
|
35
|
+
# @orgs = Organization.accessible_by(Ability.new(current_user)).sort_by { |o| o.name }
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# # GET /mnoe/jpi/v1/shopping_cart/1
|
39
|
+
# def show
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# # POST /mnoe/jpi/v1/shopping_cart
|
43
|
+
# # TODO: add test for bundle parameter on create
|
44
|
+
# def create
|
45
|
+
# organization = Organization.find(params[:shopping_cart][:organization_id])
|
46
|
+
# bundle = params[:shopping_cart][:bundle]
|
47
|
+
# authorize! :purchase, organization
|
48
|
+
#
|
49
|
+
# @cart = Shopping::Cart.create(requestor: current_user, beneficiary: organization, bundle: bundle)
|
50
|
+
#
|
51
|
+
# render 'show'
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# # PUT /mnoe/jpi/v1/shopping_cart/1/upsert_item
|
55
|
+
# def upsert_item
|
56
|
+
# @item = @cart.add_item!(params[:item])
|
57
|
+
# render 'show_item'
|
58
|
+
# end
|
59
|
+
#
|
60
|
+
# # PUT /mnoe/jpi/v1/shopping_cart/1/remove_item
|
61
|
+
# def remove_item
|
62
|
+
# @item = @cart.remove_item!(params[:item])
|
63
|
+
# render 'show_item'
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# # PUT /mnoe/jpi/v1/shopping_cart/1/checkout
|
67
|
+
# def checkout
|
68
|
+
# if @cart.checkout!(params[:credit_card])
|
69
|
+
# render 'show'
|
70
|
+
# else
|
71
|
+
# render json: @cart.errors, status: :bad_request
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# end
|
75
|
+
#
|
76
|
+
# #============================================
|
77
|
+
# # Private Methods
|
78
|
+
# #============================================
|
79
|
+
# private
|
80
|
+
# # Inject @cart and authorize access
|
81
|
+
# # TODO: use CanCan for authorization
|
82
|
+
# def inject_cart_and_authorize
|
83
|
+
# @cart = Shopping::Cart.find(params[:id])
|
84
|
+
#
|
85
|
+
# unless @cart.requestor == current_user
|
86
|
+
# render json: { errors: 'unauthorized' }, status: :unauthorized
|
87
|
+
# return false
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# return true
|
91
|
+
# end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# This controller uses nesting (under organizations) and shallow routes
|
2
|
+
module MnoEnterprise
|
3
|
+
class Jpi::V1::TeamsController < Jpi::V1::BaseResourceController
|
4
|
+
respond_to :json
|
5
|
+
|
6
|
+
# GET /mnoe/jpi/v1/organizations/:organization_id/teams
|
7
|
+
def index
|
8
|
+
authorize! :read, parent_organization
|
9
|
+
@teams = parent_organization.teams
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /mnoe/jpi/v1/teams/:id
|
13
|
+
def show
|
14
|
+
@team = MnoEnterprise::Team.find(params[:id])
|
15
|
+
authorize! :read, @team.organization
|
16
|
+
end
|
17
|
+
|
18
|
+
# POST /mnoe/jpi/v1/organizations/:organization_id/teams
|
19
|
+
def create
|
20
|
+
authorize! :manage_teams, parent_organization
|
21
|
+
@team = parent_organization.teams.create(team_params)
|
22
|
+
|
23
|
+
render 'show'
|
24
|
+
end
|
25
|
+
|
26
|
+
# PUT /mnoe/jpi/v1/teams/:id
|
27
|
+
def update
|
28
|
+
@team = MnoEnterprise::Team.find(params[:id])
|
29
|
+
authorize! :manage_teams, @team.organization
|
30
|
+
|
31
|
+
# Update regular attributes
|
32
|
+
@team.update_attributes(team_params)
|
33
|
+
|
34
|
+
# # Update permissions
|
35
|
+
if params[:team] && params[:team][:app_instances]
|
36
|
+
list = params[:team][:app_instances].select { |e| e != {} }
|
37
|
+
@team.set_access_to(list)
|
38
|
+
end
|
39
|
+
|
40
|
+
render 'show'
|
41
|
+
end
|
42
|
+
|
43
|
+
# PUT /mnoe/jpi/v1/teams/:id/add_users
|
44
|
+
def add_users
|
45
|
+
@team = MnoEnterprise::Team.find(params[:id])
|
46
|
+
authorize! :manage_teams, @team.organization
|
47
|
+
|
48
|
+
# Add users
|
49
|
+
if params[:team] && params[:team][:users]
|
50
|
+
id_list = params[:team][:users].map { |h| h[:id] }.compact
|
51
|
+
users = @team.organization.users.where('id.in' => id_list)
|
52
|
+
users.each { |u| @team.add_user(u) }
|
53
|
+
end
|
54
|
+
|
55
|
+
render 'show'
|
56
|
+
end
|
57
|
+
|
58
|
+
# PUT /mnoe/jpi/v1/teams/:id/remove_users
|
59
|
+
def remove_users
|
60
|
+
@team = MnoEnterprise::Team.find(params[:id])
|
61
|
+
authorize! :manage_teams, @team.organization
|
62
|
+
|
63
|
+
# Add users
|
64
|
+
if params[:team] && params[:team][:users]
|
65
|
+
id_list = params[:team][:users].map { |h| h[:id] }.compact
|
66
|
+
users = @team.organization.users.where('id.in' => id_list)
|
67
|
+
users.each { |u| @team.remove_user(u) }
|
68
|
+
end
|
69
|
+
|
70
|
+
render 'show'
|
71
|
+
end
|
72
|
+
|
73
|
+
# DELETE /mnoe/jpi/v1/teams/:id
|
74
|
+
def destroy
|
75
|
+
@team = MnoEnterprise::Team.find(params[:id])
|
76
|
+
authorize! :manage_teams, @team.organization
|
77
|
+
@team.destroy
|
78
|
+
|
79
|
+
head :no_content
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def team_params
|
85
|
+
params.require(:team).permit(:name)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Health Check endpoint
|
2
|
+
module MnoEnterprise
|
3
|
+
class StatusController < ApplicationController
|
4
|
+
# Simple check to see that the app is up
|
5
|
+
# Returns:
|
6
|
+
# {status: 'Ok'}
|
7
|
+
def ping
|
8
|
+
render json: {status: 'Ok'}
|
9
|
+
end
|
10
|
+
|
11
|
+
# Version check
|
12
|
+
# Returns:
|
13
|
+
# {
|
14
|
+
# 'app-version': '9061048-6811c4a',
|
15
|
+
# 'mno-enterprise-version': '0.0.1',
|
16
|
+
# 'env': 'test'
|
17
|
+
# }
|
18
|
+
def version
|
19
|
+
data = {
|
20
|
+
'app-version' => MnoEnterprise::APP_VERSION,
|
21
|
+
'mno-enteprise-version' => MnoEnterprise::VERSION,
|
22
|
+
'env' => Rails.env
|
23
|
+
}
|
24
|
+
render json: data
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class HealthCheck
|
3
|
+
# Check API connection with Mno-Hub
|
4
|
+
# any code that returns blank on success and non blank string upon failure
|
5
|
+
def self.perform_mno_hub_check
|
6
|
+
# TODO: less expensive test
|
7
|
+
if MnoEnterprise::App.first
|
8
|
+
''
|
9
|
+
else
|
10
|
+
'MNO-HUB'
|
11
|
+
end
|
12
|
+
rescue => e
|
13
|
+
"MNO-HUB: #{e}. "
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
.registration
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.login-box-wrapper
|
5
|
+
.login-box-title
|
6
|
+
%h2 You password has expired. Please renew it.
|
7
|
+
.login-box
|
8
|
+
.brand-logo
|
9
|
+
|
10
|
+
= form_for(resource, as: resource_name, url: mno_enterprise.user_password_expired_path, :html => { method: :put, class: 'form-horizontal' }) do |f|
|
11
|
+
= devise_error_messages!
|
12
|
+
|
13
|
+
.row
|
14
|
+
.col-sm-6
|
15
|
+
= f.label :current_password, "Current password"
|
16
|
+
= f.password_field :current_password, :class => 'form-control'
|
17
|
+
|
18
|
+
.row
|
19
|
+
.col-sm-6
|
20
|
+
= f.label :password, "New password"
|
21
|
+
= f.password_field :password, :class => 'form-control'
|
22
|
+
|
23
|
+
.col-sm-6
|
24
|
+
= f.label :password_confirmation, "Confirm new password"
|
25
|
+
= f.password_field :password_confirmation, :class => 'form-control'
|
26
|
+
|
27
|
+
%br
|
28
|
+
|
29
|
+
.row
|
30
|
+
.col-sm-12
|
31
|
+
.text-center
|
32
|
+
= f.submit "Change my password", class: "btn btn-warning"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
%div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}' }" }
|
2
|
+
|
3
|
+
= form_for(resource, as: resource_name, :url => mno_enterprise.user_confirmation_finalize_path, :html => { 'name' => 'loginForm', :class => 'autofill-detect text-center' }) do |f|
|
4
|
+
|
5
|
+
.row
|
6
|
+
.col-sm-12
|
7
|
+
= f.text_field :name, placeholder: "*First Name", required: true, 'ng-model' => 'user.name', class:'form-control'
|
8
|
+
|
9
|
+
%br
|
10
|
+
|
11
|
+
.row
|
12
|
+
.col-sm-12
|
13
|
+
= f.text_field :surname, placeholder: "*Last Name", required: true, 'ng-model' => 'user.surname', class: 'form-control'
|
14
|
+
|
15
|
+
- if @phone_required && MnoEnterprise.style.devise.phone_required
|
16
|
+
%br
|
17
|
+
.row
|
18
|
+
.col-sm-12
|
19
|
+
.phone
|
20
|
+
= f.select :phone_country_code, options_for_select(Country.all.map { |country,code| c = Country.new(code); ["#{c.alpha2} +#{c.country_code}", code]}, MnoEnterprise.app_country), {}, class: 'form-control unstyled'
|
21
|
+
= f.text_field :phone, placeholder: "*Phone", required: true, 'ng-model' => 'user.phone_number', class: 'form-control'
|
22
|
+
|
23
|
+
%br
|
24
|
+
|
25
|
+
- # Password: two validation styles offered
|
26
|
+
.row
|
27
|
+
.col-sm-12
|
28
|
+
- if !!MnoEnterprise.style.devise.password_complexity_deep_check
|
29
|
+
%div{'mno-password' => 'user', form: "loginForm"}
|
30
|
+
|
31
|
+
.text-center.ng-hide{ 'ng-show' => 'user.$pwdScore.showTip' }
|
32
|
+
%small.text-danger Password is not strong enough. Try mixing letters, numbers and cases
|
33
|
+
|
34
|
+
- else
|
35
|
+
.input-group
|
36
|
+
= f.password_field :password, :placeholder => "*Choose Password", 'ng-model' => 'user.password', class: 'form-control', 'ng-minlength' => 6, 'mno-password-strength' => true, "password-score" => 'user.$pwdScore', :required => true
|
37
|
+
%span.input-group-addon.classic.pw-strength-indicator{'ng-class' => 'user.$pwdScore.class' }
|
38
|
+
{{ user.$pwdScore.value }}
|
39
|
+
|
40
|
+
.text-center.ng-hide{ 'ng-show' => 'user.$pwdScore.showTip' }
|
41
|
+
%small.text-danger Password is not strong enough. Try mixing letters, numbers and cases
|
42
|
+
|
43
|
+
|
44
|
+
= f.hidden_field :confirmation_token, value: @confirmation_token
|
45
|
+
|
46
|
+
%br/
|
47
|
+
%div
|
48
|
+
%button{ :class => "btn btn-warning btn-login", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'loginForm.$invalid', 'ng-hide' => 'hasClicked' } Confirm my account
|
49
|
+
%img.ng-hide{ 'ng-src' => asset_path('mno_enterprise/loader-32x32-bg-inverse.gif'), 'ng-show' => 'hasClicked' }
|
@@ -0,0 +1,34 @@
|
|
1
|
+
.banners.promo.dark.darkblue.confirmation-lounge
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.col-md-8.col-md-offset-2
|
5
|
+
.row
|
6
|
+
.align-center
|
7
|
+
%i.fa.fa-envelope
|
8
|
+
%h4 Congratulations! We've sent you a confirmation link, please check your email inbox.
|
9
|
+
%h5 If you did not receive the email please click resend.
|
10
|
+
|
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|
|
13
|
+
- unless devise_error_messages!.empty?
|
14
|
+
%div
|
15
|
+
.alert.alert-error
|
16
|
+
%button.close{ 'data-dismiss' => "alert" } ×
|
17
|
+
= devise_error_messages!
|
18
|
+
.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' } 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
|
+
Or if you prefer you can send an email to our
|
33
|
+
= mail_to support_email, "customer care service", subject: "Signup Verification"
|
34
|
+
directly and we'll activate it for you.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
%div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}' }" }
|
2
|
+
|
3
|
+
= form_for(resource, as: resource_name, :url => mno_enterprise.user_confirmation_finalize_path, :html => { 'name' => 'loginForm', :class => 'text-center' }) do |f|
|
4
|
+
= f.hidden_field :confirmation_token, value: @confirmation_token
|
5
|
+
|
6
|
+
%div{ layout: '', 'layout-sm' => 'column' }
|
7
|
+
%md-input-container{ flex: '' }
|
8
|
+
%label Name
|
9
|
+
= f.text_field :name, required: true, 'ng-model' => 'user.name'
|
10
|
+
|
11
|
+
%md-input-container{ flex: '' }
|
12
|
+
%label Surname
|
13
|
+
= f.text_field :surname, required: true, 'ng-model' => 'user.surname'
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
- if @phone_required && MnoEnterprise.style.devise.phone_required
|
18
|
+
%div{ layout: '', 'layout-sm' => 'column' }
|
19
|
+
|
20
|
+
%md-input-container
|
21
|
+
%md-select{ placeholder: "Ext.", 'ng-model' => "user.phone_country_code", style: 'line-height: 26px;' }
|
22
|
+
%md-option{ 'ng-value' => 'opt.alpha2', 'ng-repeat' => "opt in #{ Country.all.map {|cntry, alpha2| {alpha2: alpha2, code: Country.new(alpha2).country_code} }.to_json }" }
|
23
|
+
{{ opt.alpha2 }} +{{ opt.code }}
|
24
|
+
= f.hidden_field :phone_country_code, 'ng-model' => 'user.phone_country_code'
|
25
|
+
|
26
|
+
%md-input-container{ flex: '' }
|
27
|
+
%label Phone
|
28
|
+
= f.text_field :phone, required: true, 'ng-model' => 'user.phone_number'
|
29
|
+
|
30
|
+
%div{'mno-password' => 'user', form: "loginForm"}
|
31
|
+
|
32
|
+
|
33
|
+
%div
|
34
|
+
%button{ class: "md-raised md-accent", 'md-button' => true, type: "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'loginForm.$invalid' } Create Account
|
35
|
+
|
36
|
+
%br
|
37
|
+
|
38
|
+
%div
|
39
|
+
%p
|
40
|
+
By clicking 'Create Account' you are agreeing to
|
41
|
+
= "#{MnoEnterprise.app_name}'s"
|
42
|
+
Terms of Use and Privacy Policy
|
43
|
+
|
44
|
+
%md-progress-linear{ 'md-mode' => "indeterminate", 'ng-show' => 'hasClicked' }
|