Sha256: c9ecdbb306fe7ed72a3d6e37c604b0b4941360e5a5d5e92e54df26797e5dc30a

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'vimeo'
module Admin
  class VimeoBaseController < Admin::BaseController
    
    before_filter :get_account
    
    CONSUMER_KEY_FORMAT = /[a-z0-9]{32}/
    CONSUMER_SECRET_FORMAT = /[a-z0-9]{16}/
    TOKEN_FORMAT = /[a-z0-9]{32}/
    SECRET_FORMAT = /[a-z0-9]{40}/
    
    protected
      
      # Hack because I don't know how to turn off restriction otherwise
      def restrict_plugins
      end
      
      # Hack because I don't know how to turn off restriction otherwise
      def restrict_controller
      end
      
      def ready_to_authorize?
        @account[:consumer_key] =~ CONSUMER_KEY_FORMAT and @account[:consumer_secret] =~ CONSUMER_SECRET_FORMAT
      end
  
      def authorized?
        @account[:token] =~ TOKEN_FORMAT and @account[:secret] =~ SECRET_FORMAT
      end
      
      def get_account
        @account = {
          :username => RefinerySetting.find_or_set(:vimeo_username, :value => "Username"),
          :consumer_key => RefinerySetting.find_or_set(:vimeo_consumer_key, :value => "Consumer Key"),
          :consumer_secret => RefinerySetting.find_or_set(:vimeo_consumer_secret, :value => "Consumer Secret"),
          :token => RefinerySetting.find_or_set(:vimeo_token, :value => 'Token').value,
          :secret => RefinerySetting.find_or_set(:vimeo_secret, :value => 'Secret').value}
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-vimeo-videos-0.1.3 app/controllers/admin/vimeo_base_controller.rb