Sha256: af766214d2b1edcacf6b83a49e24afa20a3ce32188ada670f481682b7223ba89

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

module MxitApi
  module ControllerExtensions
    def mxit_api
      @mxit_api ||= begin
        client = MxitApi::Client.new(MxitApi.config.mxit_app_name,
          MxitApi.config.mxit_api_client_id, MxitApi.config.mxit_api_client_secret)
      end
    end

    # type = :user | :app
    def load_mxit_auth_token type 
      auth_tokens = session[:mxit_auth_tokens]
      if auth_tokens
        auth_token = auth_tokens[type]
        if auth_token and not auth_token.has_expired?
          return auth_token
        end
      end

      nil
    end

    # type = :user | :app
    def save_mxit_auth_token type, auth_token
      auth_tokens = (session[:mxit_auth_tokens] ||= {})
      auth_tokens[type] = auth_token
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mxit-rails-0.4.3 lib/mxit_api/controller_extensions.rb
mxit-rails-0.4.2 lib/mxit_api/controller_extensions.rb
mxit-rails-0.4.1 lib/mxit_api/controller_extensions.rb