Sha256: 53aa56cdfb145f4eab47f6a1f6b689d3e1f5cb2a489bb22207068d2e7f7fce20

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

class OauthController < ApplicationController

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

  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

  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

  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.sync_enabled = false
      organization.save
    end

    redirect_to root_url
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
maestrano-connector-rails-0.3.13 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.12 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.11 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.10 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.9 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.8 lib/generators/connector/templates/oauth_controller.rb
maestrano-connector-rails-0.3.7 lib/generators/connector/templates/oauth_controller.rb