Class: Tamashii::Manager::Authorizator::Token
- Inherits:
-
Object
- Object
- Tamashii::Manager::Authorizator::Token
- Defined in:
- lib/tamashii/manager/authorizator/token.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
Instance Method Summary collapse
-
#initialize ⇒ Token
constructor
A new instance of Token.
- #verify!(data) ⇒ Object
Constructor Details
#initialize ⇒ Token
Returns a new instance of Token.
10 11 12 13 14 |
# File 'lib/tamashii/manager/authorizator/token.rb', line 10 def initialize @client_id = nil @authorized = false @type = Type::CLIENT[:agent] end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/tamashii/manager/authorizator/token.rb', line 8 def client_id @client_id end |
Instance Method Details
#verify!(data) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/tamashii/manager/authorizator/token.rb', line 16 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 Error::AuthorizationError, "Token mismatch!" unless @authorized = Config.token == token raise Error::AuthorizationError, "Device type not available!" unless Type::CLIENT.values.include?(@type.to_i) [@type.to_i, @client_id] end |