Module: MnoEnterprise::Concerns::Controllers::Webhook::OAuthController

Extended by:
ActiveSupport::Concern
Included in:
Webhook::OAuthController
Defined in:
lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb

Instance Method Summary collapse

Instance Method Details

#authorizeObject

Instance methods

GET /mnoe/webhook/oauth/:id/authorize



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb', line 57

def authorize
  if params[:redirect_path].present?
    session[:redirect_path] = params[:redirect_path]
  end

  # Certain providers require options to be selected
  if !params[:perform] && app_instance.app && PROVIDERS_WITH_OPTIONS.include?(app_instance.app.nid.to_s)
    render "mno_enterprise/webhook/o_auth/providers/#{app_instance.app.nid}"
    return
  end

  @redirect_to = MnoEnterprise.router.authorize_oauth_url(params[:id], extra_params.merge(wtk: wtk))
end

#callbackObject

GET /mnoe/webhook/oauth/:id/callback



72
73
74
75
76
77
78
79
80
81
# File 'lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb', line 72

def callback
  path = session.delete(:redirect_path).presence || mnoe_home_path

  if error_key = params.fetch(:oauth, {})[:error]

    path = add_param_to_fragment(path.to_s, 'flash', [{msg: error_message(error_key),  type: :error}.to_json])
  end

  redirect_to path
end

#disconnectObject

GET /mnoe/webhook/oauth/:id/disconnect



84
85
86
# File 'lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb', line 84

def disconnect
  redirect_to MnoEnterprise.router.disconnect_oauth_url(params[:id], extra_params.merge(wtk: wtk))
end

#syncObject

GET /mnoe/webhook/oauth/:id/sync



89
90
91
# File 'lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb', line 89

def sync
  redirect_to MnoEnterprise.router.sync_oauth_url(params[:id], extra_params.merge(wtk: wtk))
end