Sha256: 2bf7d9ab35578a9ffeeccfd2b28d052b25ad0aafdcb5e176bfd1957abf242ac3

Contents?: true

Size: 1.22 KB

Versions: 22

Compression:

Stored size: 1.22 KB

Contents

require 'killbill_client'

module Kaui
  class User < ActiveRecord::Base
    devise :killbill_authenticatable

    # Managed by Devise
    attr_accessor :password

    attr_accessible :kb_tenant_id, :kb_username, :kb_session_id, :password

    # Called by Devise to perform authentication
    # Throws KillBillClient::API::Unauthorized on failure
    def self.find_permissions(kb_username, kb_password, api_key=KillBillClient.api_key, api_secret=KillBillClient.api_secret)
      do_find_permissions :username => kb_username,
                          :password => kb_password,
                          :api_key => api_key,
                          :api_secret => api_secret
    end

    # Called by CanCan to perform authorization
    # Throws KillBillClient::API::Unauthorized on failure
    def permissions(api_key=KillBillClient.api_key, api_secret=KillBillClient.api_secret)
      User.do_find_permissions :session_id => kb_session_id,
                               :api_key => api_key,
                               :api_secret => api_secret
    end

    private

    def self.do_find_permissions(options = {})
      KillBillClient.url = Kaui.killbill_finder.call
      KillBillClient::Model::Security.find_permissions options
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kaui-0.6.5 app/models/kaui/user.rb
kaui-0.6.4 app/models/kaui/user.rb
kaui-0.6.3 app/models/kaui/user.rb
kaui-0.6.2 app/models/kaui/user.rb
kaui-0.6.1 app/models/kaui/user.rb
kaui-0.6.0 app/models/kaui/user.rb
kaui-0.5.3 app/models/kaui/user.rb
kaui-0.5.2 app/models/kaui/user.rb
kaui-0.5.1 app/models/kaui/user.rb
kaui-0.5.0 app/models/kaui/user.rb
kaui-0.4.9 app/models/kaui/user.rb
kaui-0.4.8 app/models/kaui/user.rb
kaui-0.4.7 app/models/kaui/user.rb
kaui-0.4.6 app/models/kaui/user.rb
kaui-0.4.5 app/models/kaui/user.rb
kaui-0.4.4 app/models/kaui/user.rb
kaui-0.4.3 app/models/kaui/user.rb
kaui-0.4.2 app/models/kaui/user.rb
kaui-0.4.1 app/models/kaui/user.rb
kaui-0.4.0 app/models/kaui/user.rb