Class: OauthController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/connector/templates/oauth_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_omniauthObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/connector/templates/oauth_controller.rb', line 18

def create_omniauth
  org_uid = '' # TODO
  organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, current_user.tenant)

  if organization && is_admin?(current_user, organization)
    # TODO
    # Update organization with oauth params
  end

  redirect_to root_url
end

#destroy_omniauthObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/connector/templates/oauth_controller.rb', line 30

def destroy_omniauth
  organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:organization_id])

  if organization && is_admin?(current_user, organization)
    organization.oauth_uid = nil
    organization.oauth_token = nil
    organization.refresh_token = nil
    organization.save
  end

  redirect_to root_url
end

#request_omniauthObject

TODO Routes for this controller are not provided by the gem and should be set according to your needs



7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/connector/templates/oauth_controller.rb', line 7

def request_omniauth
  if is_admin
    # TODO
    # Perform oauth request here. The oauth process should be able to
    # remember the organization, either by a param in the request or using
    # a session
  else
    redirect_to root_url
  end
end