Sha256: be4499d1b8e128251932bb81b46ad2648bb85b11f99962fe97531a135d9bae21

Contents?: true

Size: 1014 Bytes

Versions: 4

Compression:

Stored size: 1014 Bytes

Contents

module Trell
  module Authentication
    def generation_endpoint
      @api_endpoint.gsub('api.', '')
    end

    def key_generetor
      "#{generation_endpoint}appKey/generate"
    end

    def token_generator(expiration = 'never', scope = 'read,write,account')
      query = [
        "response_type=token",
        "key=#{@application_key}",
        "scope=#{scope}",
        "expiration=#{expiration}",
        "name=Trell"
      ].join('&')

      "#{generation_endpoint}authorize?#{query}"
    end

    def basic_authenticated?
      !!(@login && @password)
    end

    def token_authenticated?
      !!@access_token
    end

    def user_authenticated?
      basic_authenticated? || token_authenticated?
    end

    def application_authenticated?
      !!application_authentication
    end

    private

    def application_authentication
      if @application_key && @application_token
        {
          key: @application_key,
          token: @application_token
        }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trell-0.0.4 lib/trell/authentication.rb
trell-0.0.3 lib/trell/authentication.rb
trell-0.0.2 lib/trell/authentication.rb
trell-0.0.1 lib/trell/authentication.rb