Sha256: de6a01d40091699e97e3c495bd5bffc2440b970a2b3b94982f1494c5c5c2efe3

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

require "tamashii/manager/errors/authorization_error"
require "tamashii/manager/config"

module Tamashii
  module Manager
    module Authorizator
      class Token
        attr_reader :client_id

        def initialize
          @client_id = nil
          @authorized = false
          @type = Type::CLIENT[:agent]
        end

        def verify!(data)
          @type, @client_id, token = data.split(",")
          Manager.logger.debug("Client #{@client_id} try to verify token: #{Config.env.production? ? "FILTERED" : token}")
          raise AuthorizationError.new("Token mismatch!") unless @authorized = Config.token == token
          raise AuthorizationError.new("Device type not available!") unless Type::CLIENT.values.include?(@type.to_i)
          [@type.to_i, @client_id]
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tamashii-manager-0.1.7 lib/tamashii/manager/authorizator/token.rb
tamashii-manager-0.1.5 lib/tamashii/manager/authorizator/token.rb
tamashii-manager-0.1.4 lib/tamashii/manager/authorizator/token.rb